Your first chart with cURL
Get a free key from the pricing section and keep it in an environment variable, not in your code:
<?php
$ch = curl_init('https://simplenumerologyapi.com/v1/charts/pythagorean');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('NUMEROLOGY_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'first_name' => 'María',
'middle_name' => 'Stefania',
'last_name' => 'García López',
'birthdate' => '1990-03-12',
]),
]);
$chart = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $chart['life_path_number']; // 7
echo $chart['destiny_number']; // 5
echo $chart['soul_urge_number']; // 4
json_encode sends UTF-8, so accented names work as written.
Laravel
use Illuminate\Support\Facades\Http;
$chart = Http::withHeaders(['X-API-Key' => config('services.numerology.key')])
->timeout(10)
->post('https://simplenumerologyapi.com/v1/charts/pythagorean', [
'first_name' => $request->input('first_name'),
'last_name' => $request->input('last_name'),
'birthdate' => $request->input('birthdate'),
])
->throw()
->json();
With Guzzle in Symfony or plain PHP, it is the same request: $client->post($url, ['headers' => [...], 'json' => [...]]).
Cache it, because it never changes
The same name and birthdate always give the same chart, so store it with the user’s profile or cache it forever. A user who reloads their reading should not spend a request:
$chart = Cache::rememberForever(
'chart:' . sha1($first . '|' . $last . '|' . $birthdate),
fn () => fetchChart($first, $last, $birthdate),
);
Errors
Every error has the same JSON shape: {"error": {"code": "…", "message": "…"}}. The ones to handle:
422 parameter_invalid: a bad date or a missing name. Theerrorslist says which field, so you can show it next to the form input.402: the monthly quota is used up. Show a friendly message rather than an error page.429: too many requests a second. Wait for the number of seconds inRetry-After.
The API reference lists every error code.
Frequently asked questions
Is there a PHP SDK for the numerology API?
There is no PHP package to install, and you do not need one: the API is one JSON request. If you prefer a typed client, generate one from the OpenAPI spec with OpenAPI Generator’s PHP target.
Can I call the API from JavaScript in the browser instead?
No. The API key must stay on your server, and the API does not allow cross-origin browser calls. Call it from PHP and send the result to your page.
Does it work with WordPress?
Yes. WordPress has its own HTTP functions, and the WordPress guide shows a shortcode that uses them.
Which PHP version do I need?
Any PHP version with the cURL extension and json_encode works. The examples above run on PHP 7.4 and later.
Start with 100 free charts a month
No card, no trial clock, no expiry date.
Related
A numerology calculator for WordPress
Add a numerology calculator to a WordPress site with a numerology API and a small shortcode. Life path, destin…
Numerology API for Python
Calculate life path, destiny and soul urge numbers in Python. A free numerology REST API with JSON responses a…
Numerology API for JavaScript and Node.js
Add numerology charts to a Node.js, Next.js, Deno or Bun app with one fetch call. A free numerology REST API w…
A numerology SDK for any language
Generate a typed numerology API SDK in Go, Java, C#, PHP, Ruby, Swift, TypeScript or Python from the OpenAPI 3…