← Developer tools

cURL → Node.js and Python converter

Every endpoint page and the playground give you a curl command. Paste one here - edited or not - and get the equivalent Node.js and Python code, checked against the endpoint's schema before you run it.

Free · runs in your browser · no API key needed · updated

Endpoint: Birth Chart (Kundli) POST /v1/charts/birth · reference

javascript
const res = await fetch("https://api.astronode.dev/v1/charts/birth", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ASTRONODE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "date": "1993-07-04",
    "time": "09:27:11",
    "tz_offset_minutes": 330,
    "lat": 31.7473,
    "lng": 77.7754
  }),
});
if (!res.ok) throw new Error(`AstroNode ${res.status}: ${await res.text()}`);
const { data } = await res.json();
console.log(data);

What gets translated

curl flags the converter understands
curlBecomes
-X / --requestthe HTTP method (GET or POST)
-H 'Authorization: Bearer …'a header read from ASTRONODE_API_KEY
-d, --data, --data-raw, --jsonthe JSON body (json= in Python, JSON.stringify in Node)
-s, -N, --compressed, -Lignored - they do not change the request
-u, -F, -T, -breported as not translated

Quoting follows POSIX shells: single quotes, double quotes, '\'' escapes and backslash line continuations - the forms AstroNode's own snippets use. Windows cmd.exe ^ continuations are not supported; paste the command as one line or use the PowerShell form.

The generated code

Node.js (18+, built-in fetch) - the same generator the endpoint pages use:

javascript
const res = await fetch("https://api.astronode.dev/v1/charts/birth", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.ASTRONODE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ /* your body */ }),
});
if (!res.ok) throw new Error(`AstroNode ${res.status}: ${await res.text()}`);
const { data } = await res.json();

Python uses requests with timeout=30 and raise_for_status(). Neither version needs an SDK. Chat endpoints return their fields at the top level, so for those the code prints the whole JSON instead of data.

Checks before you run it

  • Host - is it the AstroNode API or chat origin?
  • Endpoint - does the path exist, and with this method? GET /v1/charts/birth is caught before it becomes a 404.
  • Body - every top-level field is compared with the endpoint's schema; unknown fields (a 400 VALIDATION_ERROR waiting to happen) and missing required ones are listed.
  • Key - a pasted aie_live_… or aie_test_… key is never copied into the code, and you are told to rotate it if it has been shared.

Common mistakes

  • Hard-coding the key while translating by hand. Read it from the environment, and keep the call on your server.
  • Sending the body as form data. requests.post(url, data=...) form-encodes a dict; the API needs json=.
  • Dropping `Content-Type` in Node. Without application/json the body is not parsed as JSON.
  • No timeout in Python. requests waits forever by default; the generated code sets 30 seconds.

FAQ

Is my curl command or key sent anywhere?
No. Parsing and code generation happen in your browser.
Which languages are supported?
Node.js (built-in fetch) and Python (requests), matching the tabs on every endpoint page. For other languages, the request builder gives you the JSON body to send.
Does it work for GET endpoints with path parameters?
Yes - a path such as /v1/horoscope/daily/aries is matched to its endpoint and kept as written.