Code Samples

Explore practical examples, API integrations, and implementation patterns to jumpstart your development.

API Integration Samples

Create Project

This shows how to create a new project using our REST API.

POST /api/projects
Authorization: Bearer <token>
{
  "name": "My Awesome Project",
  "description": "First project using DevHub API"
}

Response:

{
  "id": "a167d523-5b50-4e5b-89e0-d5f93312a9b5",
  "created_at": "2025-09-10T08:00:00Z"
}
                    

List User Projects

Fetch projects associated with an authenticated user

GET /api/v1/projects
Authorization: Bearer <token>

Example Response:

{
  "projects": [
    {
      "id": "b08c95c8-d38e-4606-a3af-3f148e5744a2",
      "name": "My First Project"
    },
    {
      "id": "e4d8259a-74a8-41a9-93d0-c13438f68bde",
      "name": "Production App"
    }
  ]
}
                    

Authentication Examples

Sign-In Flow

POST /auth/signin
{"email": "user@domain.com", "password": "secret123"}

Authentication response contains:

  • Access token (JWT)
  • Refresh token
  • Expiration timestamp

OAuth2 Implementation

GET /auth/google
GET /callback?code=XYZ123

OAuth2 flow with automatic token refresh and scope management.

SDK Integrations

TypeScript Example


import { DevHubClient } from '@devhub/client';

const client = new DevHubClient({
  apiKey: process.env.API_KEY
});

client.projects.create({
  name: 'My SDK Project',
  description: 'TypeScript SDK sample'
}).then(project => {
  console.log('Created project', project);
});

                        

Python Sample


from devhub import Client

client = Client(api_key="xyz123")

response = client.projects.create(
    name="Python Example",
    description="SDK Integration"
)

print(response.project_id)

                        

More Samples Available

Browse additional implementation examples in our GitHub repositories and API reference guides.