Bearing Calculation
Maps Math & Calculations Credits / request: 1Returns the initial bearing from start to target in degrees 0-360. North is 0.
GET
https://api.apikodu.com/api/v1/maps/bearing
Documentation
Overview
Bearing between two points.
Authentication
Every request requires the x-api-key header. Credits used and remaining quota are returned in response headers (x-api-credits-used, x-api-remaining-credits, x-rate-limit-*).
Request
GET
https://api.apikodu.com/api/v1/maps/bearing?fromLatitude=40.98765&fromLongitude=29.02541&toLatitude=41.037&toLongitude=28.985
Query string.
Parameters
| Name | Type | Required | Default | Options | Description |
|---|---|---|---|---|---|
fromLatitude |
number | * Required | — | — | From latitude. |
fromLongitude |
number | * Required | — | — | From longitude. |
toLatitude |
number | * Required | — | — | To latitude. |
toLongitude |
number | * Required | — | — | To longitude. |
Response
| Name | Type | Description |
|---|---|---|
bearingDegrees |
number | Initial bearing from start to end. 0–360 degrees. 0=north, 90=east. |
bearingRadians |
number | The same bearing in radians. |
Errors
| HTTP | code | Description |
|---|---|---|
400 |
-232 |
fromLatitude or toLatitude is outside -90..90. |
400 |
-233 |
fromLongitude or toLongitude is outside -180..180. |
401 |
-100 |
x-api-key is missing, empty, malformed, inactive, banned, expired, IP-restricted, or not allowed for this API. |
429 |
-221 |
Per-minute request limit exceeded. Response headers: x-rate-limit-limit, x-rate-limit-remaining, x-rate-limit-reset. |
429 |
— | Package credit quota cannot cover this request. Body may be { error, limit, currentUsage, requestCost } (no code field). |
500 |
-1 |
Unexpected server error. message is a generic error text without technical details. |
Notes
- Success body is { data: { ... } }. Error body is { code, message }. code is an ApiResponseCode enum value (negative integer).
Sample response
{
"data": {
"bearingDegrees": 328.41,
"bearingRadians": 5.73172
}
}
Code samples
const response = await fetch('https://api.apikodu.com/api/v1/maps/bearing', {
method: 'GET',
headers: {
'x-api-key': 'YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);
import requests
headers = {
'x-api-key': 'YOUR_API_KEY'
}
response = requests.get('https://api.apikodu.com/api/v1/maps/bearing', headers=headers)
print(response.json())
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", "YOUR_API_KEY");
var response = await client.GetStringAsync("https://api.apikodu.com/api/v1/maps/bearing");
Console.WriteLine(response);
$response = file_get_contents('https://api.apikodu.com/api/v1/maps/bearing', false, stream_context_create([
'http' => [
'header' => "x-api-key: YOUR_API_KEY"
]
]));
print_r(json_decode($response, true));
curl -X GET 'https://api.apikodu.com/api/v1/maps/bearing' \
-H 'x-api-key: YOUR_API_KEY'
Start building in minutes
Create a free account, get your API key and send your first request in minutes.