AstrologyAPI

Chinese Year Forecast

POSThttps://json.astrologyapi.com/v1/chinese_year_forecast
Copy

POST/chinese_year_forecast
Copy
1import requests
2import json
3
4# Your API key
5api_key = "<YOUR_API_KEY>"
6
7# API endpoint URL
8api_url = "https://json.astrologyapi.com/v1/chinese_year_forecast"
9
10# Request data
11data = {
12        "day": 10,
13        "month": 5,
14        "year": 1990,
15        "hour": 19,
16        "min": 55,
17        "lat": 19.2056,
18        "lon": 25.2056,
19        "tzone": 5.5
20    }
21
22headers = {
23    'x-astrologyapi-key': api_key,
24    'Content-Type': 'application/json'
25    # Add 'Accept-Language': '<language_code>' if needed
26}
27
28try:
29    response = requests.post(api_url, headers=headers, json=data)
30    response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)
31
32    # Process the response
33    response_data = response.json()
34    print(json.dumps(response_data, indent=4))
35
36except requests.exceptions.RequestException as e:
37    print(f"Error making API request: {e}")
38    if hasattr(e, 'response') and e.response is not None:
39        try:
40            print(f"Error response: {e.response.json()}")
41        except json.JSONDecodeError:
42             print(f"Error response (non-JSON): {e.response.text}")
43
44
200Response
Copy
1{
2  "chinese_zodiac": "rabbit",
3  "forecast_year": 2020,
4  "forecast": [
5    "You are industrious but also need to be cautious. While 2020 is bringing in new opportunities to meet your goals and ambitions, wait! Hang on! Don't get excited. Calculate is the advice we give you in a glaring sense. Avoid taking the plunge immediately. You gotta weigh the positives and negatives before you delve into unknown waters. You surely don't want to be a piece of meat for some waiting alligator down there. Don't be foolhardy; your 'golden chance' as you had felt could turn out to be a monster in hiding.",
6    "Your piggy banks would be getting full. This year, the astrological indicators are so rightly placed to endow you with good luck and money. So there could be a meaty promotion waiting for you. So as 2020 is bringing you an appraisal, we see that you also have a spending problem. Great! It's like paying the baker more than your cake is worth. Just because your hands are getting full, don't simply get onto a shopping spree. More money means more responsibility. Wisely learn the art of money management. Smart bunny, we need not tell you how important it is to save money. You know it right!",
7    "You are sensitive, romantic and considerate when it comes to love. You are about to bump into somebody whom you might just start liking. Your tenderness could be playing a key role in attracting the opposite sex. And if you wish to be your partner's munchkin for a longer time, then stop playing mysterious and better be serious right at the start.",
8    "You bunnies are known to be overly sentimental. So you gotta keep away from those strong spirits. Don't drink like a fish and appear some dipsomaniac to make matters worse. You'll start having mental sickness if you do so. Your heart, gall and liver are delicate to keep up with the rush of 2020. So take good care of yourself, and exercise dear bunnies. You so much need it to glide through 2020!",
9    "It's a year of rise and falls for you Rabbits out there. This year is kinda balanced in its good and bad, so you need not worry much.  Every good will neutralize your bad and every bad is kicking you to perform better. Dark is sexy, but you gotta avoid it. And some evening your sweetheart might ask you to accompany for a walk by the water. Avoid it too. And if you feel like taking the cake, the baker and the bakery with you, then let us warn you, that too on a serious note; don't be greedy!"
10  ]
11}

Request Headers

Authorization

string

required

Basic Authorization via header

Accept-Language

string

Preferred language for the response content

Properties

English - en

Request Parameters

day

int

required

Date of birth, eg: 10

month

int

required

Month of birth, eg: 5

year

int

required

Year of birth, eg: 1990

hour

int

required

Hour of birth, eg: 19

min

int

required

Minute of birth, eg: 55

lat

float

required

Latitude, eg: 19.2056

lon

float

required

Longitude, eg: 25.2056

tzone

float

required

Timezone, eg: 5.5

Errors

400
Bad Request

Something is wrong with your request format or parameters.

401
Unauthorized

Your API key is missing or invalid.

403
Forbidden

You don't have permission to access this specific resource.

404
Not Found

The API endpoint you're trying to reach doesn't exist.

500
Internal Server Error

Our server is having a temporary glitch.