{"id":29485735,"url":"https://github.com/aaronsb/gong-api-client","last_synced_at":"2026-02-23T08:02:20.621Z","repository":{"id":280524107,"uuid":"942293890","full_name":"aaronsb/gong-api-client","owner":"aaronsb","description":"A Node.js library that automatically generates a TypeScript client for the Gong API from the OpenAPI specification, providing both generated client and direct HTTP request approaches for interacting with Gong's conversation analytics platform.","archived":false,"fork":false,"pushed_at":"2025-03-04T02:43:35.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-16T13:24:47.995Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aaronsb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-03T22:05:43.000Z","updated_at":"2025-07-22T23:19:28.000Z","dependencies_parsed_at":"2025-03-03T22:33:04.832Z","dependency_job_id":null,"html_url":"https://github.com/aaronsb/gong-api-client","commit_stats":null,"previous_names":["aaronsb/gong-api-client"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aaronsb/gong-api-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Fgong-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Fgong-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Fgong-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Fgong-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aaronsb","download_url":"https://codeload.github.com/aaronsb/gong-api-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aaronsb%2Fgong-api-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273842866,"owners_count":25177921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-15T06:01:56.670Z","updated_at":"2025-10-25T02:48:30.196Z","avatar_url":"https://github.com/aaronsb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gong API Client\n\nA Node.js library that automatically generates a TypeScript client for the Gong API from the OpenAPI specification.\n\nThis package provides two approaches to working with the Gong API:\n1. **Generated TypeScript Client**: A fully typed client generated from the OpenAPI specification\n2. **Direct HTTP Requests**: A simpler approach using direct HTTP requests with basic authentication\n\n## Features\n\n- Automatically downloads the latest Gong API specification\n- Generates TypeScript client code organized by API endpoint groups\n- Provides a simple interface for interacting with the Gong API\n- Supports authentication with API key and access key\n- Includes TypeScript type definitions for all API requests and responses\n- Offers a direct HTTP request approach for simpler use cases\n\n## Installation\n\n```bash\nnpm install gong-api-client\n```\n\nFor the direct HTTP approach, you only need axios:\n\n```bash\nnpm install axios\n```\n\n## Authentication\n\nThe Gong API uses basic authentication with your API credentials:\n\n- **Access Key**: Used as the username\n- **Access Key Secret**: Used as the password\n\n## Configuration\n\nYou can configure the Gong API client using environment variables or by passing options directly to the `initGongApiClient` function.\n\n### Using Environment Variables\n\nCreate a `.env` file in your project root:\n\n```\n# Gong API Configuration\nGONG_BASE_URL=https://api.gong.io\nGONG_API_KEY=your-api-key\nGONG_ACCESS_KEY=your-access-key\n\n# Optional: Specify custom paths for the API specification and generated client\n# GONG_SPEC_FILE=./custom-gong-api.json\n# GONG_OUTPUT_DIR=./custom-client\n```\n\nThen load the environment variables in your code:\n\n```typescript\nimport { initGongApiClient } from 'gong-api-client';\nimport * as dotenv from 'dotenv';\n\n// Load environment variables from .env file\ndotenv.config();\n\nasync function main() {\n  // Initialize the client (will use environment variables automatically)\n  const gongClient = await initGongApiClient();\n  \n  // Use the client to make API calls\n  // ...\n}\n```\n\n### Direct Configuration\n\n```typescript\nimport { initGongApiClient } from 'gong-api-client';\n\nasync function main() {\n  // Initialize the client with explicit options\n  const gongClient = await initGongApiClient({\n    baseUrl: 'https://api.gong.io',\n    apiKey: 'your-api-key',\n    accessKey: 'your-access-key'\n  });\n\n  // Use the client to make API calls\n  // ...\n}\n```\n\n## Usage\n\n### Direct HTTP Approach\n\nThis simpler approach uses direct HTTP requests with basic authentication:\n\n```javascript\nconst axios = require('axios');\n\n// Your Gong API credentials\nconst baseUrl = 'https://api.gong.io';\nconst accessKey = 'YOUR_ACCESS_KEY';\nconst accessKeySecret = 'YOUR_ACCESS_KEY_SECRET';\n\n// Create a client with basic authentication\nconst gongClient = axios.create({\n  baseURL: baseUrl,\n  auth: {\n    username: accessKey,\n    password: accessKeySecret\n  },\n  headers: {\n    'Content-Type': 'application/json'\n  }\n});\n\n// Make API requests\nasync function getUsers() {\n  try {\n    const response = await gongClient.get('/v2/users');\n    console.log(`Retrieved ${response.data.records.totalRecords} users`);\n    return response.data;\n  } catch (error) {\n    console.error('Error:', error.message);\n    if (error.response) {\n      console.error('Status:', error.response.status);\n      console.error('Data:', error.response.data);\n    }\n  }\n}\n\ngetUsers();\n```\n\n### Generated Client Approach\n\n```typescript\nimport { initGongApiClient } from 'gong-api-client';\nimport * as dotenv from 'dotenv';\n\n// Load environment variables from .env file\ndotenv.config();\n\nasync function main() {\n  // Initialize the client\n  const gongClient = await initGongApiClient();\n\n  // Use the client to make API calls\n  try {\n    // Example: Get all users\n    const users = await gongClient.UsersService.getUsers();\n    console.log('Users:', users);\n\n    // Example: Get call details\n    const callId = '123456789';\n    const call = await gongClient.CallsService.getCall(callId);\n    console.log('Call details:', call);\n  } catch (error) {\n    console.error('Error:', error);\n  }\n}\n\nmain();\n```\n\n### Advanced Usage\n\n```typescript\nimport { initGongApiClient, downloadAndSaveGongSpec, generateGongApiClient } from 'gong-api-client';\nimport * as dotenv from 'dotenv';\nimport path from 'path';\n\n// Load environment variables from .env file\ndotenv.config();\n\nasync function main() {\n  // Download the latest API specification\n  const specFile = path.join(__dirname, 'custom-gong-api.json');\n  await downloadAndSaveGongSpec(specFile);\n\n  // Generate the client code\n  const outputDir = path.join(__dirname, 'custom-client');\n  await generateGongApiClient(specFile, outputDir);\n\n  // Initialize the client with custom options\n  const gongClient = await initGongApiClient({\n    baseUrl: process.env.GONG_BASE_URL,\n    apiKey: process.env.GONG_API_KEY,\n    accessKey: process.env.GONG_ACCESS_KEY,\n    specFile,\n    outputDir,\n    regenerate: false // We already generated the client code\n  });\n\n  // Use the client to make API calls\n  // ...\n}\n\nmain();\n```\n\n## API Reference\n\n### initGongApiClient(options)\n\nInitializes the Gong API client.\n\n#### Options\n\n- `baseUrl` (string, optional): Base URL for the Gong API. Default: 'https://api.gong.io'\n- `apiKey` (string, optional): API key for authentication.\n- `accessKey` (string, optional): Access key for authentication.\n- `specFile` (string, optional): Path to the API specification file. Default: 'gong-openapi.json'\n- `outputDir` (string, optional): Directory to output the generated code. Default: 'src/generated'\n- `regenerate` (boolean, optional): Whether to regenerate the client code. Default: false\n\n#### Returns\n\nA promise that resolves to the generated client object.\n\n### downloadAndSaveGongSpec(outputFile)\n\nDownloads the Gong API specification and saves it to a file.\n\n#### Parameters\n\n- `outputFile` (string, optional): Path to save the API specification. Default: 'gong-openapi.json'\n\n#### Returns\n\nA promise that resolves to the path of the saved file.\n\n### generateGongApiClient(specFile, outputDir)\n\nGenerates TypeScript client code from the Gong API specification.\n\n#### Parameters\n\n- `specFile` (string, optional): Path to the API specification file. Default: 'gong-openapi.json'\n- `outputDir` (string, optional): Directory to output the generated code. Default: 'src/generated'\n\n#### Returns\n\nA promise that resolves when the client code has been generated.\n\n## Common API Endpoints\n\n- `/v2/users` - Get a list of users\n- `/v2/users/{userId}` - Get details for a specific user\n- `/v2/calls` - Get a list of calls\n- `/v2/calls/{callId}` - Get details for a specific call\n\n## API Structure\n\nThe generated client provides direct access to all services and models from the Gong API:\n\n### Services\n\nThe client exposes service classes that correspond to the different functional areas of the Gong API:\n\n- `CallsService`: Methods for working with call recordings\n- `UsersService`: Methods for managing users\n- `StatsService`: Methods for retrieving statistics\n- `SettingsService`: Methods for managing settings\n- `DataPrivacyService`: Methods for data privacy operations\n- `LibraryService`: Methods for library operations\n- `CRMService`: Methods for CRM integration\n- `AuditingService`: Methods for auditing operations\n- `MeetingsService`: Methods for meeting operations (Beta)\n- `PermissionsService`: Methods for permission management\n- `EngageFlowsService`: Methods for engage flows\n- `DigitalInteractionsService`: Methods for digital interactions\n- `IntegrationSettingsService`: Methods for integration settings\n\n### Models\n\nThe client also provides TypeScript interfaces for all data models used in the API:\n\n- Request and response types for all API operations\n- Data models for entities like calls, users, statistics, etc.\n\n## Best Practices\n\n1. **Error Handling**: Always implement proper error handling for API requests\n2. **Rate Limiting**: Be mindful of API rate limits\n3. **Pagination**: Use cursor-based pagination for endpoints that return large datasets\n4. **Security**: Keep your API credentials secure and never commit them to version control\n\n## Pagination\n\nThe Gong API uses cursor-based pagination for endpoints that return large datasets. When making a request to an endpoint that supports pagination:\n\n1. The initial response includes a `records` object with pagination information:\n   ```json\n   {\n     \"records\": {\n       \"totalRecords\": 150,\n       \"currentPageSize\": 50,\n       \"currentPageNumber\": 1,\n       \"cursor\": \"eyJpZCI6MTIzNDV9\"\n     },\n     \"data\": [...]\n   }\n   ```\n\n2. To retrieve the next page of results, make the same request again but include the `cursor` value from the previous response:\n   ```typescript\n   // First request\n   const firstPage = await gongClient.CallsService.listCalls({\n     fromDateTime: '2023-01-01T00:00:00Z',\n     toDateTime: '2023-01-31T23:59:59Z'\n   });\n\n   // If there are more records to retrieve\n   if (firstPage.records?.cursor) {\n     // Second request with cursor\n     const secondPage = await gongClient.CallsService.listCalls({\n       fromDateTime: '2023-01-01T00:00:00Z',\n       toDateTime: '2023-01-31T23:59:59Z',\n       cursor: firstPage.records.cursor\n     });\n   }\n   ```\n\n3. Continue this process until the response no longer includes a `cursor` value, indicating that all records have been retrieved.\n\nThis pagination method is more efficient than traditional offset-based pagination and ensures consistent results even when the underlying data changes between requests.\n\n## Troubleshooting\n\n- If you receive a 401 Unauthorized error, check that your API credentials are correct\n- If you're using the generated client and encounter errors, try the direct HTTP approach with axios\n- Make sure your API key has the necessary permissions for the endpoints you're trying to access\n\n## Development\n\n### Building the Library\n\n```bash\nnpm run build\n```\n\n### Running Tests\n\n```bash\nnpm test\n```\n\n## Continuous Integration and Deployment\n\nThis project uses GitHub Actions for continuous integration and deployment.\n\n### CI Workflow\n\nThe CI workflow runs on every push to the main branch and on pull requests. It:\n\n- Builds the project on multiple Node.js versions\n- Runs tests (when added)\n\n### Publishing to npm\n\nThe package is automatically published to npm when:\n\n- Changes are pushed to the main branch that modify package.json\n- A new GitHub release is created\n- The workflow is manually triggered\n\nTo set up automatic publishing:\n\n1. Generate an npm access token:\n   - Go to npmjs.com and log in\n   - Click on your profile icon → Access Tokens\n   - Click \"Generate New Token\" (select \"Automation\" type)\n   - Copy the generated token\n\n2. Add the token to GitHub repository secrets:\n   - Go to your GitHub repository\n   - Click on Settings → Secrets and variables → Actions\n   - Click \"New repository secret\"\n   - Name: `NPM_TOKEN`\n   - Value: paste your npm token\n   - Click \"Add secret\"\n\n## License\n\nMIT\n\n## Author\n\nAaron Bockelie\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronsb%2Fgong-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faaronsb%2Fgong-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faaronsb%2Fgong-api-client/lists"}