Skip to content

⚠️ WORK IN PROGRESS

This wiki is under active development. Information may be incomplete or inaccurate.

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

IconAccess LevelRequired
🌐PublicNo API key needed
🔑LimitedLimited access API key required
🔐FullFull access API key required

For exact access levels per endpoint, see the Swagger API Reference.

Code Examples

javascript
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));
python
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']}")
bash
# 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:

json
{
  "name": "Stellar Industries",
  "cash": 5000000
}

Error:

json
{
  "error": "Rate limit exceeded"
}

HTTP Status Codes

CodeMeaning
200Success
401Invalid or missing API key
403Insufficient access level
404Resource not found
429Rate limit exceeded
503Game server is starting/shutting down

Rate Limiting

All endpoints have a cost measured in points:

MethodRate LimitWindow
With API Key (User-based)200 points5 minutes
Without API Key (IP-based)100 points5 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:

HeaderDescription
Rate-RemainingPoints remaining in current window
Rate-ResetSeconds until rate limit window resets
Retry-After(429 only) Seconds to wait before retrying

Example response headers:

http
Rate-Remaining: 150
Rate-Reset: 240

Anti-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 DurationData SharingPurposeKey StorageAccess 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 answerYour answerYour answerYour answerYour 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.