Womens Health: Menstrual Cycle, Phase Predictions & Insights

FREEMIUM
By DataFenix | Updated il y a 2 mois | Health and Fitness
Popularity

8.1 / 10

Latency

1,337ms

Service Level

100%

Health Check

100%

Back to All Tutorials (1)

Guide to Womens Health API: Features, Glossary, and Developer Workflow

Welcome to our Womens Health API, a powerful tool designed to predict menstrual cycles and phases with precision. This guide will walk you through the functionalities of our API, demonstrating how to integrate cycle predictions into your health or wellness app seamlessly.

Step 1: Predict Future Cycle Dates with /process_cycle_data
Start by sending a POST request to our /process_cycle_data endpoint. This endpoint requires a JSON payload containing the current date (or whichever date you’d like to make predictions for), past cycle data (past_cycle_data) and an optional maximum number of cycle predictions (max_cycle_predictions). Here’s a brief overview of what you need:

past_cycle_data: An array of objects, each representing a past cycle with cycle_start_date and period_length.
max_cycle_predictions: The maximum number of future cycle predictions you wish to generate. Max is 12, default is 6.
This request will return a request_id that you can use to fetch detailed analysis results. This approach minimizes data transmission by allowing you to request only the information you need when you need it.

Step 2: Retrieve Analysis Results with /get_data/{request_id}/{field}
Once you have your request_id, you can retrieve specific pieces of the analysis using the /get_data/{request_id}/{field} endpoint. Replace {request_id} with your unique ID and {field} with the specific piece of information you need, such as predicted_cycle_starts or average_cycle_length. See the Glossary below for the data fields you can retrieve.

Example workflow (python)

import requests

BASE_URL = "https://womens-health-menstrual-cycle-phase-predictions-insights.p.rapidapi.com"
# BASE_URL = "http://127.0.0.1:8000"

headers = {
	"X-RapidAPI-Key": YOUR_API_KEY,
	"X-RapidAPI-Host": "womens-health-menstrual-cycle-phase-predictions-insights.p.rapidapi.com"
}

# Step 1: Call /process_cycle_data to analyze past cycle data and get a request_id
past_data_payload = {
    "current_date": "2023-05-15",
    "past_cycle_data": [
        {"cycle_start_date": "2023-01-05", "period_length": 5}, 
        {"cycle_start_date": "2023-02-01", "period_length": 4},
        {"cycle_start_date": "2023-02-28", "period_length": 4},
        {"cycle_start_date": "2023-03-26", "period_length": 5},
        {"cycle_start_date": "2023-04-20", "period_length": 5},
        ],
    "max_cycle_predictions": 6
}
response = requests.post(f"{BASE_URL}/process_cycle_data", json=past_data_payload, headers=headers)
# print(response.json())
request_id = response.json()["request_id"]

# Step 2: Use the request_id to get specific fields like "predicted_cycle_starts" and "average_period_length"
predicted_starts_response = requests.get(f"{BASE_URL}/get_data/{request_id}/predicted_cycle_starts", headers=headers)
predicted_starts = predicted_starts_response.json()["predicted_cycle_starts"]
print(predicted_starts)

average_period_length_response = requests.get(f"{BASE_URL}/get_data/{request_id}/average_period_length", headers=headers)
average_period_length = average_period_length_response.json()["average_period_length"]
print(average_period_length)

# Get int value of average_period_length, round to nearest whole number
average_period_length_int = round(float(average_period_length))
print(average_period_length_int)

# Step 3: Use two consecutive predicted start dates and average_period_length as input for /predict_cycle_phases
cycle_phase_payload = {
    "cycle_start_date": predicted_starts[0],
    "next_cycle_start_date": predicted_starts[1],
    "period_length": average_period_length_int
}
phase_prediction_response = requests.post(f"{BASE_URL}/predict_cycle_phases", json=cycle_phase_payload, headers=headers)
print(phase_prediction_response.json())

Glossary of /get_data Fields

  • predicted_cycle_starts: A list of predicted cycle start dates starting from the cycle following the latest cycle in the input data. Use max_cycle_predictions parameter in the /process_cycle_data to determine how many cycles to return (max 12, default 6)

  • next_future_cycle_start: The next predicted cycle date, relative to the current_date field

  • next_cycle_start_range: Provides a range (earliest and latest) for the next cycle start date, along with a confidence level, aiding in uncertainty management. Confidence is currently set to 80%. You can tell you users “We are 80% confident your period will start between date 1 and date 2”.

  • average_cycle_length: The average length of the menstrual cycle based on past data

  • std_cycle_length: Standard deviation of the cycle length, indicating variability and regularity in the cycle.

  • average_period_length: Average duration of menstruation, critical for understanding individual health patterns and used in phase predictions.

  • irregular_cycle_count: Count of cycles considered irregular based on one being outside of the 21 to 35 day range.

  • regular_cycle_count: Count of cycles considered regular, assisting in establishing baselines for predictions.

  • irregular_cycles_flag: Based on the cycles provided, this is a determination about whether the user should be classified as “having irregular cycles”. This is based on average_cycle_length being outside the range of 21 to 35 days.

  • irregular_cycles_type: Describes the type of irregularity detected (polymenorrhea, oligomenorrhea or regular), providing specific insights for personalized health advice.

  • prediction_confidence: Overall confidence in the cycle predictions, based on the count of valid cycles provided.