onparlay-api-client
v1.0.1
Published
Type-safe API client for OnParlay backend
Maintainers
Readme
@onparlay/api-client
Type-safe API client for OnParlay backend, automatically generated from OpenAPI/Swagger specification.
Installation
npm install @onparlay/api-clientNo authentication needed - the package is published to npm public registry.
Usage
import { bulkCreateMatchEntries, MatchEntryData } from "@onparlay/api-client";
// Configure base URL (optional, defaults to http://localhost:3333)
process.env.API_BASE_URL = "https://api.onparlay.com";
const matchEntries: MatchEntryData[] = [
{
startDate: "2024-12-25T15:00:00Z",
homeTeam: "Manchester United",
awayTeam: "Liverpool",
competition: "Premier League",
country: "England",
},
];
const result = await bulkCreateMatchEntries({
sportName: "Football",
sportsbookName: "Bwin",
matchEntries,
});
console.log(`Created ${result.count} match entries`);Development
Generate API Client
Simple way (copies from backend repo and generates):
npm run generate:from-backendThis will:
- Copy
openapi.jsonfrom../onparlay-backend/openapi.json - Generate the TypeScript client from it
Manual steps:
First, export the OpenAPI spec from the backend:
cd ../onparlay-backend npm run export:openapiCopy it to this repo (or use the script):
npm run copy-openapiGenerate the client:
npm run generate
From running backend (alternative):
# Make sure backend is running on http://localhost:3333
OPENAPI_SPEC_URL=http://localhost:3333/api-json npm run generateWatch mode (regenerates on changes):
npm run generate:watchBuild
npm run buildPublish New Version
Patch version (bug fixes):
npm run publish:patchMinor version (new features):
npm run publish:minorMajor version (breaking changes):
npm run publish:majorOr manually:
npm version patch # or minor/major
npm publishNote: You need to be logged in to npm and have 2FA enabled (required for scoped packages):
Enable 2FA on npm:
- Go to: https://www.npmjs.com/settings/[your-username]/security
- Enable "Two-factor authentication"
- Follow the setup instructions
Login to npm:
npm loginPublish:
npm publish
Alternative: If you don't want to use 2FA, create a granular access token:
- Go to: https://www.npmjs.com/settings/[your-username]/tokens
- Create token with "Automation" type and "Bypass 2FA" enabled
- Use it with:
npm publish --access public
Configuration
The API client uses axios and can be configured via environment variables:
API_BASE_URL: Base URL for API requests (default:http://localhost:3333)
Versioning
This package follows Semantic Versioning:
- Major: Breaking API changes
- Minor: New features, backward compatible
- Patch: Bug fixes, documentation
License
UNLICENSED
