Create API Key
POST
/keys
curl -X POST https://api.astroway.info/v1/keys \ -H "X-Api-Key: aw_live_..." \ -H "Content-Type: application/json" \ -d '{ "name": "My App", "plan": "free" }'const res = await fetch('https://api.astroway.info/v1/keys', { method: 'POST', headers: { 'X-Api-Key': process.env.ASTROWAY_API_KEY, 'Content-Type': 'application/json', }, body: JSON.stringify({ "name": "My App", "plan": "free" }),});const { ok, data, error } = await res.json();if (!ok) throw new Error(error.message);console.log(data);import os, requests
r = requests.post( 'https://api.astroway.info/v1/keys', headers={'X-Api-Key': os.environ['ASTROWAY_API_KEY'], 'Content-Type': 'application/json'}, json={ 'name': "My App", 'plan': "free" },)result = r.json()if not result['ok']: raise RuntimeError(result['error']['message'])print(result['data'])<?phpuse GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://api.astroway.info/v1/']);$r = $client->post('keys', [ 'headers' => ['X-Api-Key' => getenv('ASTROWAY_API_KEY')], 'json' => [ 'name' => 'My App', 'plan' => 'free', ],]);$result = json_decode($r->getBody(), true);if (!$result['ok']) throw new \RuntimeException($result['error']['message']);print_r($result['data']);Create a new API key. Requires an internal or enterprise API key. Returns the generated key string — save it, it cannot be retrieved later.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ” Media type application/json
object
name required
string
mode
string
origin_restriction
object
type
string
allowed_origins
Array<string>
Example
{ "name": "My App", "plan": "free"}Responses
Section titled “ Responses ”Successful calculation
Media type application/json
object
ok
boolean
data
object
apiKey
string
name
string
plan
string
rateLimit
number
Example
{ "ok": true, "data": { "apiKey": "aw_free_a1b2c3d4e5f6a1b2c3d4e5f6", "name": "My App", "plan": "free", "rateLimit": 10 }}Validation error
Media type application/json
Example
{ "ok": false, "error": { "code": "INVALID_INPUT", "message": "Validation failed: date: Date must be YYYY-MM-DD", "details": [ { "path": "date", "message": "Date must be YYYY-MM-DD" } ] }}Missing or invalid API key
Media type application/json
Example
{ "ok": false, "error": { "code": "INVALID_API_KEY", "message": "Invalid API key" }} Корисно?
Дякуємо за фідбек.