Prerequisites
Before you begin, make sure you have:- Created a MoonKey app in the dashboard
- Obtained your API keys from the dashboard
Base URL
All requests to the MoonKey API must be made to the following base URL:Authentication
The MoonKey API uses Bearer token authentication. You must include your API key in theAuthorization header of every request.
API Keys
MoonKey provides two types of API keys:| Key Type | Format | Usage | Security |
|---|---|---|---|
| Test Keys | sk_test_... | Development and testing | Safe to use in test environments |
| Live Keys | sk_live_... | Production | Keep secure, never expose in client code |
Authentication Header
Include your API key in theAuthorization header using the Bearer scheme:
Required Headers
Every API request must include these headers:Bearer token with your MoonKey API key (test or live).Example:
Bearer sk_test_pRqweh3wvWmJAAVYv7Z0T5iPLzFM4ql0muoyQcjOxGeN3p1rSet to
application/json for all requests with a body.Getting Your API Keys
Retrieve your API keys from the MoonKey Dashboard:- Log in to your MoonKey Dashboard
- Select your app from the dropdown
- Navigate to API Keys in the sidebar
- Copy your test or live API key
- Store it securely in your environment variables
Example Requests
Here are examples of making authenticated requests to the MoonKey API in different languages:- cURL
- JavaScript
- Node.js
- Python
- Go
Making POST Requests
For requests that create or update resources, include a JSON body:- cURL
- JavaScript
- Python
Environment Variables
Store your API keys securely using environment variables:.env
- Node.js
- Python
- Next.js
Response Format
All API responses are returned in JSON format with consistent structure:Success Response
Error Response
HTTP Status Codes
The MoonKey API uses standard HTTP status codes:| Status Code | Meaning |
|---|---|
200 | Success - Request completed successfully |
201 | Created - Resource created successfully |
400 | Bad Request - Invalid request parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - API key doesn’t have required permissions |
404 | Not Found - Resource doesn’t exist |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Something went wrong on our end |
Rate Limiting
The MoonKey API implements rate limiting to ensure service reliability:- Test environment: 100 requests per minute
- Production environment: 1000 requests per minute
429 status code. The response includes headers indicating when you can retry:
Best Practices
Security
- Never expose API keys in client-side code - API keys should only be used from your backend
- Use environment variables - Store keys in
.envfiles and never commit them to version control - Rotate keys regularly - Generate new keys periodically and revoke old ones
- Use test keys in development - Keep live keys separate and only use them in production
Error Handling
Always implement proper error handling:Testing Your Integration
Test your API integration with these steps:- Use test API keys - Start with
sk_test_...keys - Test authentication - Verify your API key works by fetching user data
- Handle errors - Test error scenarios (invalid keys, missing parameters, etc.)
- Check rate limits - Ensure your application handles rate limiting properly
- Validate responses - Verify response structure matches documentation
Next Steps
Now that you’ve set up API authentication, explore the available endpoints:Authentication
Manage user authentication and sessions
Users
Create and manage user accounts
Wallets
Create and manage user wallets
Sessions
Verify and manage user sessions
Support
Need help with the REST API?- Check the API Reference for detailed endpoint documentation
- Review code examples for common patterns
- Contact support for technical assistance