Client Registration and Authentication
To use the SplitScreen API, you first need to register your client. This will give you a client ID, API key, and client secret, which you will use to authenticate your requests.
1. Registering your client
To register your client, you need to send a POST request to the /v1/client endpoint. The body of the request should contain the following JSON data:
{
"name": "Your Client Name"
}
The response will contain your client ID, API key, and client secret:
{
"client_id": "your-client-id",
"api_key": "your-api-key",
"client_secret": "your-client-secret"
}
Important: Store these credentials securely. The client secret is only returned once during registration and cannot be retrieved later.
2. Obtaining a JWT Access Token
Before making API requests, you need to obtain a JWT access token by calling the /v1/token endpoint with your credentials.
Send a POST request to /v1/token with the following JSON body:
{
"client_id": "your-client-id",
"api_key": "your-api-key",
"client_secret": "your-client-secret"
}
The response will contain your JWT access token:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "bearer",
"expires_in": 3600
}
3. Authenticating your requests
To authenticate your requests, you need to include an Authorization header with the value Bearer your-access-token:
curl -X GET "https://api.splitscreen-example.com/v1/users" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Note: The JWT token expires after 1 hour (3600 seconds). You'll need to obtain a new token when it expires.
Example: Complete Registration Flow
Here's a complete example of the registration and authentication process:
# 1. Register your client
curl -X POST https://api.splitscreen-example.com/v1/client \
-H "Content-Type: application/json" \
-d '{"name": "My Awesome Game"}'
# Response:
# {
# "client_id": "myawesomegame-abc123",
# "api_key": "your-api-key-here",
# "client_secret": "your-client-secret-here"
# }
# 2. Get JWT token
curl -X POST https://api.splitscreen-example.com/v1/token \
-H "Content-Type: application/json" \
-d '{
"client_id": "myawesomegame-abc123",
"api_key": "your-api-key-here",
"client_secret": "your-client-secret-here"
}'
# Response:
# {
# "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
# "token_type": "bearer",
# "expires_in": 3600
# }
# 3. Use the token for API calls
curl -X GET https://api.splitscreen-example.com/v1/users \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."