AstroWay/api v2.180.1 · vi
tất cả hệ thống hoạt động bình thường

Khởi động nhanh API chiêm tinh: TypeScript và Python trong 5 phút

Cài đặt SDK, nhận API-key, thực hiện yêu cầu đầu tiên về bản đồ sao. 5 phút - và bạn có JSON hoạt động (TypeScript và Python).

🕓 Ghi chú từ 2026-04-14, cập nhật 2026-05-09. TS / Python / PHP SDK hiện đã có trên public registries - @astroway/sdk (npm), astroway (PyPI), astroway/sdk (Packagist). Chi tiết ở changelog.

Bạn muốn tính bản đồ sinh từ code. Đây là con đường ngắn nhất - chỉ trong 5 phút từ đầu đến JSON hoạt động.

Đăng ký tại api.astroway.info/dashboard/sign-up. Gói miễn phí: 10 000 credit / tháng. Không cần thẻ.

Trong dashboard nhấn «Create key» → «Production» → sao chép. Các khóa có dạng aw_live_aB3xY7pQ9rN2mK4jH8vC5tL6wZ1fD0eR.

Mẹo: cũng có sandbox-key với tiền tố aw_test_ - chúng không trừ credit. Hãy dùng chúng khi phát triển.

Terminal window
npm install @astroway/sdk
Terminal window
pip install astroway

Cả hai SDK đều bao phủ tất cả 758 endpoint với các yêu cầu và phản hồi được kiểu hoá.

import { Astroway } from '@astroway/sdk';
const aw = new Astroway({
apiKey: process.env.ASTROWAY_API_KEY!,
});
const chart = await aw.chart.compute({
date: '1990-07-14',
time: '14:30:00',
timezoneOffset: 3, // UTC+3, літо в Києві
latitude: 50.4501,
longitude: 30.5234,
houseSystem: 'P', // Placidus
});
const SIGNS = ['Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo',
'Libra', 'Scorpio', 'Sagittarius', 'Capricorn', 'Aquarius', 'Pisces'];
const sun = chart.planets.find((p) => p.name === 'Sun')!;
console.log(`Sun: ${SIGNS[Math.floor(sun.longitude / 30)]} at ${sun.longitude.toFixed(2)}°`);
console.log(`ASC: ${chart.houses.ascendant.toFixed(2)}°`);
console.log(`Aspects: ${chart.aspects.length}`);

Chạy:

Terminal window
ASTROWAY_API_KEY=aw_live_... npx tsx chart.ts

Tệp sử dụng top-level await, vì vậy trong package.json phải có "type": "module". Nếu không tsx sẽ bị lỗi với Top-level await is currently not supported with the "cjs" output format.

from astroway import Astroway, BirthData
aw = Astroway(api_key="aw_live_your_key_here")
chart = aw.chart.compute(BirthData(
date="1990-07-14",
time="14:30:00",
timezone_offset=3,
latitude=50.4501,
longitude=30.5234,
house_system="P",
))
SIGNS = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo",
"Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"]
sun = next(p for p in chart["planets"] if p["name"] == "Sun")
print(f"Sun: {SIGNS[int(sun['longitude'] // 30)]} at {sun['longitude']:.2f}°")
print(f"ASC: {chart['houses']['ascendant']:.2f}°")
print(f"Aspects: {len(chart['aspects'])}")

Chạy:

Terminal window
ASTROWAY_API_KEY=aw_live_... python3 chart.py

Trả về một đối tượng JSON với bốn phần chính:

Mảng gồm 13 đối tượng. Trong name là tên của thiên thể từ Swiss Ephemeris: Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto, true Node (North Node), mean Apogee (Lilith), Chiron.

{
"id": 0,
"name": "Sun",
"longitude": 354.702, // еклiптична довгота у градусах
"latitude": -0.00016,
"distance": 0.9945, // в астрономічних одиницях
"speedLong": 0.9971, // градусів на день (від'ємне = ретроград)
"speedLat": 0.00003,
"speedDist": 0.00019,
"isRetrograde": false,
"declination": -1.4159,
"rightAscension": 355.437
}

Dấu và cung không có ở đây: tính dấu bằng Math.floor(longitude / 30), còn cung lấy từ các cusp trong houses.

Cusp các cung (12 mục), cùng với asc và MC:

{
"system": "P",
"cusps": [118.18, 138.27, ...], // 12 значень
"ascendant": 118.18,
"mc": 12.708,
"armc": 11.69,
"vertex": 253.97,
"equatorialAsc": 100.75,
"coAscWK": 81.13,
"coAscMunkasey": 123.7,
"polarAsc": 261.13
}

Mảng các khía cạnh giữa các hành tinh:

{
"planet1": "Sun",
"planet2": "Mercury",
"planet1Id": 0,
"planet2Id": 2,
"type": { // об'єкт, не рядок
"name": "Conjunction",
"i18nKey": "aspect_conjunction",
"angle": 0,
"orb": 12,
"symbol": "",
"isMajor": true,
"color": "#660480"
},
"exactAngle": 3.365,
"orb": 3.365, // відхилення від точного у градусах
"isApplying": true
}

"diurnal" (Mặt Trời trên chân trời tại thời điểm sinh) hoặc "nocturnal" (dưới chân trời). Được dùng trong chiêm tinh cổ điển.

Bạn có thể thử:

Synastry: tính tương hợp của hai người:

const synastry = await client.synastry({
chart1: { date: '1990-07-14', time: '14:30:00', timezoneOffset: 3, latitude: 50.45, longitude: 30.52 },
chart2: { date: '1992-03-22', time: '09:15:00', timezoneOffset: 2, latitude: 48.85, longitude: 2.35 },
});
console.log(`Compatibility score: ${synastry.compatibility.score}/100`);

Current transits on natal chart:

const transits = await client.transits({
// дані народження
date: '1990-07-14', time: '14:30:00', timezoneOffset: 3,
latitude: 50.4501, longitude: 30.5234,
// дата транзиту
transitDate: '2026-04-14',
});

Daily horoscope from real transits:

const horoscope = await client.horoscopeDaily({
date: '1990-07-14', time: '14:30:00', timezoneOffset: 3,
latitude: 50.4501, longitude: 30.5234,
});
console.log(horoscope.text);

Full Human Design chart:

const hd = await client.humanDesign({
date: '1990-07-14', time: '14:30:00', timezoneOffset: 3,
latitude: 50.4501, longitude: 30.5234,
});
console.log(`${hd.type} - ${hd.strategy} - Profile ${hd.profile}`);
  • Bản đồ sinh (/chart): 20 credit
  • Synastry: 50 credit
  • Transits: 50 credit
  • Daily horoscope: 20 credit
  • Human Design: 50 credit

Gói miễn phí: 10 000 credit / tháng = 500 bản đồ sinh, hoặc 200 synastry, hoặc tải hỗn hợp.

Mỗi phản hồi chứa các header với credit:

X-Credits-Used: 20
X-Credits-Remaining: 4980
X-Credits-Reset: 2026-05-01T00:00:00Z

Khi credit hết - bạn sẽ nhận được 402 Payment Required. Khi vượt rate-limit (Free: 10 yêu cầu / phút) - 429 Too Many Requests với header Retry-After.

SDK ném các lỗi đã được kiểu hoá, có thể bắt:

import { QuotaExceededError, RateLimitError } from '@astroway/sdk';
try {
const chart = await aw.chart.compute(birth);
} catch (err) {
if (err instanceof QuotaExceededError) {
console.log('Upgrade plan or wait for reset');
} else if (err instanceof RateLimitError) {
console.log(`Retry in ${err.retryAfterSeconds ?? 60} seconds`);
} else {
throw err;
}
}

Bạn nên bắt từ cụ thể đến chung: tất cả chúng kế thừa ApiError, vì vậy kiểm tra ApiError đầu tiên sẽ bắt được các lỗi còn lại.

Bây giờ bạn có:

  • API-key hoạt động
  • SDK đã cài đặt
  • Bản đồ sinh đầu tiên
  • Đủ ví dụ để thêm synastry, transits, horoscopes

Đọc tiếp:

MakSeong · AstroWay

I build the AstroWay API: Swiss Ephemeris on a clean REST surface, and I write about the dull parts that turn out to matter.

// xây dựng trên nền tảng này

Chính Swiss Ephemeris giống như trong Solar Fire - chỉ trong 4 dòng code.

Khóa API miễn phí không cần thẻ. 5.000 lượt gọi/tháng trước lần thanh toán đầu tiên.

Thêm từ blog tất cả bài viết →

Industry 2026-06-05

Free Astrology API: Which One Has the Best Free Tier in 2026?

A side-by-side of free tiers across the major astrology APIs - credits, request caps, card requirements - and how much you can actually build for free.

Engineering 2026-06-05

Horoscope API Tutorial: Build a Daily Horoscope Feature

Add daily, weekly and monthly horoscopes to your app via API - sign-based text vs transit-based personalization - with TypeScript and Python code.

Engineering 2026-06-05

Natal Chart API in PHP: SDK + Laravel Example

Compute a natal chart in PHP with the AstroWay SDK - plain PHP and a Laravel facade - without compiling a Swiss Ephemeris extension.