GraphQL Proxy
Access the GraphQL API through Bounty Lab's infrastructure with built-in rate limit protection.
Bounty Lab provides a transparent proxy to the GraphQL API, allowing you to query data in real-time without worrying about rate limits, token management, or API complexity.
Why Use the GraphQL Proxy?
Section titled “Why Use the GraphQL Proxy?”Benefits
Section titled “Benefits”- No Token Required: Use your Bounty Lab API key instead
- Rate Limit Protection: We handle rate limiting for you
- Real-Time Data: Get the latest data directly from the source
- Full GraphQL Access: Use any GraphQL query (read-only)
- Simplified Authentication: Single authentication method across all services
When to Use It
Section titled “When to Use It”Use the GraphQL proxy when you need:
- Real-time data (Bounty Lab’s cached data can be up to 48 hours old)
- Data not available in our RAW or SEARCH endpoints
- Custom GraphQL queries for specific use cases
Cost: 50 credits per query. For cost optimization, prefer RAW (1 credit) or SEARCH (1 credit) endpoints when possible.
Quick Comparison
Section titled “Quick Comparison”Using the GraphQL API Directly
Section titled “Using the GraphQL API Directly”Without Bounty Lab, you need to:
- Create a personal access token
- Manage rate limits yourself (5,000 points per hour)
- Handle authentication headers
- Deal with rate limit errors and implement backoff logic
# Direct GraphQL API callcurl -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -X POST \ -d '{"query":"{ viewer { login name } }"}' \ https://api.github.com/graphqlUsing Bounty Lab’s GraphQL Proxy
Section titled “Using Bounty Lab’s GraphQL Proxy”With Bounty Lab:
- Use your Bounty Lab API key
- We handle rate limiting automatically
- Simple authentication
- No token management needed
# Bounty Lab GraphQL Proxycurl -H "Authorization: Bearer YOUR_BOUNTYLAB_API_KEY" \ -H "Content-Type: application/json" \ -X POST \ -d '{"query":"{ viewer { login name } }"}' \ https://api.bountylab.io/api/github/graphqlGetting Started
Section titled “Getting Started”Prerequisites
Section titled “Prerequisites”- A Bounty Lab account
- An API key with
GITHUB_GRAPHQLservice enabled - Sufficient credits (50 credits per query)
Basic Usage
Section titled “Basic Usage”The endpoint accepts standard GraphQL queries using POST requests:
Endpoint: https://api.bountylab.io/api/github/graphql
Method: POST
Headers:
Authorization: Bearer YOUR_API_KEYContent-Type:application/json(Required)
Important: The
Content-Type: application/jsonheader is required for all requests. Without it, the API will not be able to parse your request body and will return an error.
Body:
{ "query": "YOUR_GRAPHQL_QUERY", "variables": {}}Examples
Section titled “Examples”Example 1: Get User Information
Section titled “Example 1: Get User Information”Fetch detailed information about a user.
Bounty Lab Proxy:
curl -H "Authorization: Bearer bl_YourBountyLabKey456..." \ -H "Content-Type: application/json" \ -X POST \ -d '{ "query": "query($login: String!) { user(login: $login) { login name bio company location followers { totalCount } repositories { totalCount } } }", "variables": {"login": "torvalds"} }' \ https://api.bountylab.io/api/github/graphqlResponse:
{ "data": { "user": { "login": "torvalds", "name": "Linus Torvalds", "bio": "Creator of Linux", "company": "Linux Foundation", "location": "Portland, OR", "followers": { "totalCount": 182500 }, "repositories": { "totalCount": 8 } } }}Example 2: Get Repository Details
Section titled “Example 2: Get Repository Details”Fetch information about a specific repository including stars, forks, and languages.
Bounty Lab Proxy:
curl -H "Authorization: Bearer bl_YourBountyLabKey456..." \ -H "Content-Type: application/json" \ -X POST \ -d '{ "query": "query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { name description stargazerCount forkCount languages(first: 5) { nodes { name } } primaryLanguage { name } } }", "variables": {"owner": "facebook", "name": "react"} }' \ https://api.bountylab.io/api/github/graphqlResponse:
{ "data": { "repository": { "name": "react", "description": "The library for web and native user interfaces", "stargazerCount": 228000, "forkCount": 46500, "languages": { "nodes": [ { "name": "JavaScript" }, { "name": "HTML" }, { "name": "CSS" } ] }, "primaryLanguage": { "name": "JavaScript" } } }}Example 3: Search Repositories
Section titled “Example 3: Search Repositories”Search for repositories matching specific criteria.
Bounty Lab Proxy:
curl -H "Authorization: Bearer bl_YourBountyLabKey456..." \ -H "Content-Type: application/json" \ -X POST \ -d '{ "query": "query($query: String!) { search(query: $query, type: REPOSITORY, first: 10) { nodes { ... on Repository { name owner { login } stargazerCount description } } } }", "variables": {"query": "language:rust stars:>1000"} }' \ https://api.bountylab.io/api/github/graphqlExample 4: Get User’s Recent Contributions
Section titled “Example 4: Get User’s Recent Contributions”Fetch a user’s recent contribution activity.
Bounty Lab Proxy:
curl -H "Authorization: Bearer bl_YourBountyLabKey456..." \ -H "Content-Type: application/json" \ -X POST \ -d '{ "query": "query($login: String!) { user(login: $login) { contributionsCollection { totalCommitContributions totalIssueContributions totalPullRequestContributions totalPullRequestReviewContributions } } }", "variables": {"login": "tj"} }' \ https://api.bountylab.io/api/github/graphqlResponse:
{ "data": { "user": { "contributionsCollection": { "totalCommitContributions": 1250, "totalIssueContributions": 89, "totalPullRequestContributions": 234, "totalPullRequestReviewContributions": 156 } } }}JavaScript/Node.js Example
Section titled “JavaScript/Node.js Example”Here’s how to use the proxy in a Node.js application:
const fetchGraphQL = async (query, variables = {}) => { const response = await fetch("https://api.bountylab.io/api/github/graphql", { method: "POST", headers: { Authorization: `Bearer ${process.env.BOUNTYLAB_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ query, variables }), });
const data = await response.json();
if (data.errors) { throw new Error(`GraphQL Error: ${JSON.stringify(data.errors)}`); }
return data.data;};
// Usageconst getUserInfo = async (username) => { const query = ` query($login: String!) { user(login: $login) { login name bio followers { totalCount } } } `;
return await fetchGraphQL(query, { login: username });};
// Call itgetUserInfo("torvalds").then(console.log);Python Example
Section titled “Python Example”Using the proxy in Python:
import requestsimport os
def fetch_graphql(query, variables=None): """Fetch data via Bounty Lab's GraphQL proxy.""" response = requests.post( 'https://api.bountylab.io/api/github/graphql', json={'query': query, 'variables': variables or {}}, headers={ 'Authorization': f'Bearer {os.environ["BOUNTYLAB_API_KEY"]}', 'Content-Type': 'application/json' } )
data = response.json()
if 'errors' in data: raise Exception(f"GraphQL Error: {data['errors']}")
return data['data']
# Usagequery = """query($login: String!) { user(login: $login) { login name bio followers { totalCount } }}"""
result = fetch_graphql(query, {'login': 'torvalds'})print(result)Best Practices
Section titled “Best Practices”1. Use Variables
Section titled “1. Use Variables”Always use GraphQL variables instead of string interpolation:
Good:
query($login: String!) { user(login: $login) { ... }}Bad:
query { user(login: "hardcoded") { ... }}2. Request Only What You Need
Section titled “2. Request Only What You Need”GraphQL allows you to specify exactly which fields you need:
Good (only get what you need):
{ user(login: "torvalds") { login name }}Bad (requesting unnecessary data):
{ user(login: "torvalds") { login name bio company location email websiteUrl ... # lots of fields you don't use }}3. Prefer RAW/SEARCH When Possible
Section titled “3. Prefer RAW/SEARCH When Possible”The GraphQL proxy costs 50 credits per query. Use our RAW or SEARCH endpoints (1 credit each) when they provide the data you need.
Example:
- Need user profile data? Use
/api/raw/user/:username(1 credit) - Need to search repositories? Use
/api/search/repos(1 credit) - Need real-time data or custom query? Use GraphQL proxy (50 credits)
4. Handle Errors Gracefully
Section titled “4. Handle Errors Gracefully”Always check for errors in the response:
const data = await response.json();
if (data.errors) { console.error("GraphQL errors:", data.errors); // Handle errors appropriately}Rate Limits & Costs
Section titled “Rate Limits & Costs”Credits
Section titled “Credits”- Cost: 50 credits per query
- This is significantly higher than RAW (1 credit) or SEARCH (1 credit) endpoints
- Use GraphQL proxy only when necessary
Rate Limiting
Section titled “Rate Limiting”- We handle rate limiting for you
- You’re only limited by your Bounty Lab credit balance
- No need to track rate limit points
Optimization Tips
Section titled “Optimization Tips”- Batch multiple queries into one when possible
- Use pagination efficiently
- Cache responses on your end when appropriate
- Consider using RAW/SEARCH endpoints for common queries
Limitations
Section titled “Limitations”Read-Only Access
Section titled “Read-Only Access”The proxy provides read-only access. You cannot:
- Create, update, or delete repositories
- Create issues or pull requests
- Modify user settings
- Perform any mutations
Query Complexity
Section titled “Query Complexity”Very complex queries may be rejected due to complexity limits.
Need Help?
Section titled “Need Help?”- Explore the GraphQL Explorer
- Review our Authentication Guide
- Contact support through your dashboard