Skip to content

Predict API

Predict API will help you to get tarot interpretations and numerology meanings.

API Endpoints Reference

predict_tarot_interpretations async

predict_tarot_interpretations(request: TarotAPIRequest) -> TarotAPIResponse
Method Path Description
POST /predict/tarot-interpretations Get tarot interpretations
PARAMETER DESCRIPTION
request

The request object containing the name, question, past_card, present_card, and future_card.

TYPE: TarotAPIRequest

RETURNS DESCRIPTION
TarotAPIResponse

The response object containing the name, question, and interpretations.

TYPE: TarotAPIResponse

Note

This function uses the TarotReader module to get the tarot interpretations.

Example Request

{
    "name": "John Doe",
    "question": "Will my current love last forever?",
    "past_card": {
        "name" : "Chariot",
        "is_upright" : false
    },
    "present_card": {
        "name" : "The Fool",
        "is_upright" : true
    },
    "future_card": {
        "name" : "The Magician",
        "is_upright" : true
    }
}

Example Response

{
    "interpretations": [
        {
            "card_name": "Chariot (Reversed)",
            "position": "past",
            "orientation": "ureversed",
            "meaning": "Past influence:...",
        },
        {
            "card_name": "The Fool (Upright)",
            "position": "present",
            "orientation": "upright",
            "meaning": "Present situation:...",
        },
        {
            "card_name": "The Magician (Upright)",
            "position": "future",
            "orientation": "upright",
            "meaning": "Future outlook:...",
        },
    ],
    "summary": "..."
}
Source code in api/index.py
@app.post("/predict/tarot-interpretations", response_model=TarotAPIResponse, tags=["Predict API"])
async def predict_tarot_interpretations(request: TarotAPIRequest) -> TarotAPIResponse:
    """
    | Method | Path                             | Description                                       |
    | ------ | -------------------------------- | ------------------------------------------------- |
    | `POST` | `/predict/tarot-interpretations` | Get tarot interpretations

    Params:
        request (TarotAPIRequest): The request object containing the name, question, past_card, present_card, and future_card.

    Returns:
        TarotAPIResponse: The response object containing the name, question, and interpretations.

    !!! note
        This function uses the `TarotReader` module to get the tarot interpretations.

    !!! example "Example Request"

        ```json
        {
            "name": "John Doe",
            "question": "Will my current love last forever?",
            "past_card": {
                "name" : "Chariot",
                "is_upright" : false
            },
            "present_card": {
                "name" : "The Fool",
                "is_upright" : true
            },
            "future_card": {
                "name" : "The Magician",
                "is_upright" : true
            }
        }
        ```

    !!! example "Example Response"

        ```json
        {
            "interpretations": [
                {
                    "card_name": "Chariot (Reversed)",
                    "position": "past",
                    "orientation": "ureversed",
                    "meaning": "Past influence:...",
                },
                {
                    "card_name": "The Fool (Upright)",
                    "position": "present",
                    "orientation": "upright",
                    "meaning": "Present situation:...",
                },
                {
                    "card_name": "The Magician (Upright)",
                    "position": "future",
                    "orientation": "upright",
                    "meaning": "Future outlook:...",
                },
            ],
            "summary": "..."
        }
        ```
    """
    try:
        interpretations, summary = await TAROT_READER.generate_reading(
            name=request.name,
            question=request.question,
            past_card=request.past_card,
            present_card=request.present_card,
            future_card=request.future_card,
        )

        return TarotAPIResponse(
            interpretations=interpretations,
            summary=summary,
        )

    except HTTPException:
        raise
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Internal Server Error: {str(e)}")

predict_numerology_interpretations async

predict_numerology_interpretations(request: NumerologyAPIRequest) -> NumerologyAPIResponse
Method Path Description
POST /predict/numerology-interpretations Get numerology interpretations and meanings
PARAMETER DESCRIPTION
request

The request object containing the name, dob, and question.

TYPE: NumerologyAPIRequest

RETURNS DESCRIPTION
NumerologyAPIResponse

The response object containing the numerology meaning.

TYPE: NumerologyAPIResponse

Note

This function uses the NumerologyReader module to get the numerology meaning.

Example Request

{
    "name": "John Doe",
    "dob": "1990-01-01",
    "question": "Will my current love last forever?"
}

Example Response

{
    "numerology_meaning": "..."
}
Source code in api/index.py
@app.post("/predict/numerology-interpretations", response_model=NumerologyAPIResponse, tags=["Predict API"])
async def predict_numerology_interpretations(request: NumerologyAPIRequest) -> NumerologyAPIResponse:
    """
    | Method | Path                                  | Description                                 |
    | ------ | ------------------------------------- | ------------------------------------------- |
    | `POST` | `/predict/numerology-interpretations` | Get numerology interpretations and meanings |

    Params:
        request (NumerologyAPIRequest): The request object containing the name, dob, and question.

    Returns:
        NumerologyAPIResponse: The response object containing the numerology meaning.

    !!! note
        This function uses the `NumerologyReader` module to get the numerology meaning.

    !!! example "Example Request"

        ```json
        {
            "name": "John Doe",
            "dob": "1990-01-01",
            "question": "Will my current love last forever?"
        }
        ```

    !!! example "Example Response"

        ```json
        {
            "numerology_meaning": "..."
        }
        ```
    """
    try:
        numerology_meaning = await NUMEROLOGY_READER.analyze(
            name=request.name,
            dob=request.dob,
            question=request.question,
        )

        return NumerologyAPIResponse(numerology_meaning=numerology_meaning)

    except HTTPException:
        raise
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Internal Server Error: {str(e)}")

Models Reference

TarotAPIRequest pydantic-model

Show JSON schema:
{
  "$defs": {
    "TarotCard": {
      "properties": {
        "name": {
          "title": "Name",
          "type": "string"
        },
        "is_upright": {
          "title": "Is Upright",
          "type": "boolean"
        },
        "image_url": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Image Url"
        }
      },
      "required": [
        "name",
        "is_upright"
      ],
      "title": "TarotCard",
      "type": "object"
    }
  },
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "question": {
      "title": "Question",
      "type": "string"
    },
    "past_card": {
      "$ref": "#/$defs/TarotCard"
    },
    "present_card": {
      "$ref": "#/$defs/TarotCard"
    },
    "future_card": {
      "$ref": "#/$defs/TarotCard"
    }
  },
  "required": [
    "name",
    "question",
    "past_card",
    "present_card",
    "future_card"
  ],
  "title": "TarotAPIRequest",
  "type": "object"
}

Fields:

  • name (str)
  • question (str)
  • past_card (TarotCard)
  • present_card (TarotCard)
  • future_card (TarotCard)

TarotAPIResponse pydantic-model

Show JSON schema:
{
  "$defs": {
    "TarotInterpretation": {
      "properties": {
        "card_name": {
          "title": "Card Name",
          "type": "string"
        },
        "position": {
          "enum": [
            "past",
            "present",
            "future"
          ],
          "title": "Position",
          "type": "string"
        },
        "orientation": {
          "enum": [
            "upright",
            "reversed"
          ],
          "title": "Orientation",
          "type": "string"
        },
        "meaning": {
          "title": "Meaning",
          "type": "string"
        }
      },
      "required": [
        "card_name",
        "position",
        "orientation",
        "meaning"
      ],
      "title": "TarotInterpretation",
      "type": "object"
    }
  },
  "properties": {
    "interpretations": {
      "items": {
        "$ref": "#/$defs/TarotInterpretation"
      },
      "title": "Interpretations",
      "type": "array"
    },
    "summary": {
      "title": "Summary",
      "type": "string"
    }
  },
  "required": [
    "interpretations",
    "summary"
  ],
  "title": "TarotAPIResponse",
  "type": "object"
}

Fields:

  • interpretations (List[TarotInterpretation])
  • summary (str)

TarotCard pydantic-model

Show JSON schema:
{
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "is_upright": {
      "title": "Is Upright",
      "type": "boolean"
    },
    "image_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Image Url"
    }
  },
  "required": [
    "name",
    "is_upright"
  ],
  "title": "TarotCard",
  "type": "object"
}

Fields:

  • name (str)
  • is_upright (bool)
  • image_url (Optional[str])

TarotInterpretation pydantic-model

Show JSON schema:
{
  "properties": {
    "card_name": {
      "title": "Card Name",
      "type": "string"
    },
    "position": {
      "enum": [
        "past",
        "present",
        "future"
      ],
      "title": "Position",
      "type": "string"
    },
    "orientation": {
      "enum": [
        "upright",
        "reversed"
      ],
      "title": "Orientation",
      "type": "string"
    },
    "meaning": {
      "title": "Meaning",
      "type": "string"
    }
  },
  "required": [
    "card_name",
    "position",
    "orientation",
    "meaning"
  ],
  "title": "TarotInterpretation",
  "type": "object"
}

Fields:

  • card_name (str)
  • position (Literal['past', 'present', 'future'])
  • orientation (Literal['upright', 'reversed'])
  • meaning (str)

NumerologyAPIRequest pydantic-model

Show JSON schema:
{
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "dob": {
      "title": "Dob",
      "type": "string"
    },
    "question": {
      "title": "Question",
      "type": "string"
    }
  },
  "required": [
    "name",
    "dob",
    "question"
  ],
  "title": "NumerologyAPIRequest",
  "type": "object"
}

Fields:

  • name (str)
  • dob (str)
  • question (str)

Validators:

  • validate_dob_formatdob

NumerologyAPIResponse pydantic-model

Show JSON schema:
{
  "properties": {
    "numerology_meaning": {
      "title": "Numerology Meaning",
      "type": "string"
    }
  },
  "required": [
    "numerology_meaning"
  ],
  "title": "NumerologyAPIResponse",
  "type": "object"
}

Fields:

  • numerology_meaning (str)