Starship Rewards API

Countries

Access country reference data and details

Countries

Access country reference data including country codes, names, and supported currencies.

List Countries

Get a list of all available countries.

Endpoint

GET /api/v1/countries

Authentication: Bearer token required

Query Parameters

ParameterTypeRequiredDescription
limitnumberNoNumber of results per page (default: 50, max: 10000)
pagenumberNoPage number (default: 1)
searchstringNoSearch countries by name or code

Response

Headers

X-Page: 1
X-Per-Page: 50
X-Total-Count: 195
X-Total-Pages: 4
X-Page-Size: 50
X-Has-More: true

Body

[
  {
    "id": 1,
    "code": "US",
    "name": "United States",
    "currency_code": "USD",
    "is_active": true,
    "created_at": "2023-01-01T00:00:00Z",
    "updated_at": "2023-01-01T00:00:00Z"
  },
  {
    "id": 2,
    "code": "GB",
    "name": "United Kingdom",
    "currency_code": "GBP",
    "is_active": true,
    "created_at": "2023-01-01T00:00:00Z",
    "updated_at": "2023-01-01T00:00:00Z"
  }
]

Pagination Headers

HeaderTypeDescription
X-PagenumberCurrent page number
X-Per-PagenumberItems per page
X-Total-CountnumberTotal number of items
X-Total-PagesnumberTotal number of pages
X-Page-SizenumberActual items in current page
X-Has-MorebooleanWhether more pages are available

Country Object

FieldTypeDescription
idnumberUnique country identifier
codestringISO 3166-1 alpha-2 country code
namestringCountry display name
currency_codestringISO 4217 currency code
is_activebooleanWhether country is active/supported
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp

Examples

# Get all countries (use -i to see headers)
curl -X GET "{{host}}/api/v1/countries" -i \
  -H "Authorization: Bearer your_access_token"

# Search for specific countries with pagination headers
curl -X GET "{{host}}/api/v1/countries?search=united&limit=10" -i \
  -H "Authorization: Bearer your_access_token"
<?php
function getCountries($accessToken, $limit = 50, $page = 1, $search = null) {
    $params = [
        'limit' => $limit,
        'page' => $page
    ];

    if ($search) {
        $params['search'] = $search;
    }

    $url = '{{host}}/api/v1/countries?' . http_build_query($params);

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Authorization: Bearer ' . $accessToken
    ]);

    $response = curl_exec($ch);
    $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $headers = substr($response, 0, $header_size);
    $body = substr($response, $header_size);

    // Parse headers
    $headers_array = [];
    foreach (explode("\r\n", $headers) as $header) {
        if (strpos($header, 'X-') === 0) {
            list($key, $value) = explode(': ', $header, 2);
            $headers_array[$key] = $value;
        }
    }

    curl_close($ch);

    return [
        'data' => json_decode($body, true),
        'pagination' => [
            'page' => intval($headers_array['X-Page'] ?? 1),
            'per_page' => intval($headers_array['X-Per-Page'] ?? 50),
            'total_count' => intval($headers_array['X-Total-Count'] ?? 0),
            'total_pages' => intval($headers_array['X-Total-Pages'] ?? 0),
            'page_size' => intval($headers_array['X-Page-Size'] ?? 0),
            'has_more' => ($headers_array['X-Has-More'] ?? 'false') === 'true'
        ]
    ];
}
?>

Get Country by ID

Get details for a specific country.

Endpoint

GET /api/v1/countries/{id}

Authentication: Bearer token required

Path Parameters

ParameterTypeRequiredDescription
idnumberYesCountry ID

Response

{
  "id": 1,
  "code": "US",
  "name": "United States",
  "currency_code": "USD",
  "is_active": true,
  "created_at": "2023-01-01T00:00:00Z",
  "updated_at": "2023-01-01T00:00:00Z"
}

Error Responses

404 Not Found

{
  "error": "Not Found",
  "message": "Country not found"
}

Examples

curl -X GET "{{host}}/api/v1/countries/1" \
  -H "Authorization: Bearer your_access_token"
<?php
function getCountryById($accessToken, $countryId) {
    $ch = curl_init("{{host}}/api/v1/countries/{$countryId}");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Authorization: Bearer ' . $accessToken
    ]);

    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($httpCode === 404) {
        throw new Exception("Country not found: {$countryId}");
    }

    return json_decode($response, true);
}
?>