Public API
Access Galactic Tycoons game data programmatically to build custom tools.
Base URL: https://api.g2.galactictycoons.com
API Reference: api.g2.galactictycoons.com/swagger - Complete endpoint reference with live testing
API Keys
API keys are tied to in-game Company and provide access to request information for that company.
Getting Your Company API Key
You can generate an API key for your company in the in-game Settings window.
WARNING
Be careful where you share your key, as it provides access to your company data.
Endpoint Access Levels
| Icon | Access Level | Required |
|---|---|---|
| 🌐 | Public | No API key needed |
| 🔑 | Limited | Limited access API key required |
| 🔐 | Full | Full access API key required |
For exact access levels per endpoint, see the Swagger API Reference.
Code Examples
const API_KEY = process.env.GT_API_KEY;
async function getCompany() {
const response = await fetch('https://api.g2.galactictycoons.com/public/company', {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error);
}
return await response.json();
}
// Usage
getCompany()
.then(data => console.log(data))
.catch(err => console.error(err));import requests
API_KEY = 'YOUR_API_KEY'
BASE_URL = 'https://api.g2.galactictycoons.com'
headers = {'Authorization': f'Bearer {API_KEY}'}
response = requests.get(f'{BASE_URL}/public/exchange/mat-prices', headers=headers)
if response.status_code == 200:
prices = response.json()
print(prices)
else:
print(f"Error: {response.json()['error']}")# Get company info
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.g2.galactictycoons.com/public/company
# Get material prices
curl "https://api.g2.galactictycoons.com/public/exchange/mat-prices?apikey=YOUR_API_KEY"Response Format
All responses are JSON.
Success:
{
"name": "Stellar Industries",
"cash": 5000000
}Error:
{
"error": "Rate limit exceeded"
}HTTP Status Codes
| Code | Meaning |
|---|---|
200 | Success |
401 | Invalid or missing API key |
403 | Insufficient access level |
404 | Resource not found |
429 | Rate limit exceeded |
503 | Game server is starting/shutting down |
Rate Limiting
All endpoints have a cost measured in points:
| Method | Rate Limit | Window |
|---|---|---|
| With API Key (User-based) | 200 points | 5 minutes |
| Without API Key (IP-based) | 100 points | 5 minutes |
Each endpoint shows its cost in the Swagger documentation. When you exceed the limit, you'll receive a 429 Too Many Requests response.
Rate Limit Headers
All responses include rate limit information in headers:
| Header | Description |
|---|---|
Rate-Remaining | Points remaining in current window |
Rate-Reset | Seconds until rate limit window resets |
Retry-After | (429 only) Seconds to wait before retrying |
Example response headers:
Rate-Remaining: 150
Rate-Reset: 240Anti-Spam Protection
WARNING
Repeatedly calling the API while rate-limited extends your wait time. Each rejected request pushes your reset window forward by 1 second.
Best practice: Always respect the Retry-After header value and wait before retrying.
API Terms of Service Guidelines
When creating any tool, script, website, or service that uses player API keys, you must clearly disclose how you handle user data and API keys.
Acceptable Usage
- Never request passwords - Only API keys should be requested from users
- Secure storage - API keys and data must be stored securely and kept confidential
- Optimize requests - Only request the data you need to reduce server load
- Honor key permissions - Respect the access level of each API key
- Remove invalid keys - Handle errors properly and remove disabled keys to avoid rate limits
Prohibited Activities
- Using API keys for purposes not disclosed to the key owner
- Sharing or selling user data and/or keys without explicit permission
- Exploiting gathered data from other players to gain unfair competitive advantages
- Creating any service/tool/script that violates Galactic Tycoons Terms of Service: https://galactictycoons.com/terms
- Misrepresenting how API keys will be used
Required Disclosure
All services must clearly state how they use API keys by providing the following information to the user:
| Data Storage Duration | Data Sharing | Purpose | Key Storage | Access Level |
|---|---|---|---|---|
| How long is data stored? | Who can access the data? | What is it used for? | How is the key stored? | What access level is needed? |
| Your answer | Your answer | Your answer | Your answer | Your answer |
Data Storage: None / Local only / Temporary (less than 1 day) / Persistent (until account deletion) / Permanent
Data Sharing: Nobody / Guild members / Service owners / Public aggregated statistics / Public
Key Storage: Not stored / Local browser / Database / Encrypted in database
Used Access Level: Public / Limited / Full
Enforcement
- All API usage is logged and monitored
- Violations may result in permanent API bans for keys, users, and IP addresses
- Services found violating these guidelines can be blocked from API access
- Report suspected API key misuse to the Galactic Tycoons team
Important
By using/handling/storing another player's API key, you accept responsibility for handling their data securely.