OpenXAPI provides standardized OpenAPI and AsyncAPI specifications for cryptocurrency exchanges and DeFi protocols, enabling seamless integration and SDK generation across multiple programming languages.
OpenXAPI is a Go program that automatically generates OpenAPI Specifications from various cryptocurrency exchange API documentation. It enables automatic SDK generation for multiple programming languages using the generated OpenAPI Specs.
OpenXAPI also maintains AsyncAPI Specifications for cryptocurrency exchanges and DeFi protocols. So that you can use the same specification to generate websocket client SDKs for multiple programming languages.
- Automatic OpenAPI 3.0 specification generation from exchange API docs
- AsyncAPI specification for exchanges and DeFi protocols
- Multi-language SDK generation support
- Support for multiple cryptocurrency exchanges and DeFi protocols
- Configurable API documentation URL management
- Change detection and automatic spec regeneration
- Version history tracking
- Sample file support for offline development and testing
Exchange | Product | Sub Products | REST API | Websocket API |
---|---|---|---|---|
Spot | ✅ Spot Trading ✅ Margin Trading ✅ Algo Trading ✅ Wallet ✅ Copy Trading ✅ Convert ✅ Sub Account ✅ Binance Link ✅ Futures Data ✅ Portfolio Margin Pro ✅ Staking ✅ Dual Investment ✅ Mining ✅ Crypto Loan ✅ VIP Loan ✅ C2C ✅ Fiat ✅ NFT ✅ Gift Card ✅ Rebate ✅ Simple Earn ✅ Binance Pay History |
OpenAPI, Swagger | ||
USDS-M Futures | ✅ USDS Margined Futures ✅ Binance Link |
OpenAPI, Swagger | ||
COIN-M Futures | ✅ COIN Margined Futures | OpenAPI, Swagger | ||
Options | ✅ Options | OpenAPI, Swagger | ||
Portfolio Margin | ✅ Portfolio Margin | OpenAPI, Swagger |
Exchange | Go | Python | JavaScript | Rust |
---|---|---|---|---|
Github |
Github |
Github |
Github |
.
├── bin/ # Compiled binaries
├── cmd/ # Command-line applications
│ └── openxapi/ # Main application entry point
├── configs/ # Configuration files
│ └── config.yaml # Exchange API documentation URLs and settings
├── generator-configs/ # OpenAPI Generator-specific configurations
├── history/ # Version history of generated specs
├── internal/ # Private application code
│ ├── config/ # Configuration management
│ ├── exchange/ # Exchange-specific implementations
│ ├── generator/ # OpenAPI spec generation logic
│ └── parser/ # API documentation parsers
├── samples/ # Sample API documentation files
│ └── binance/ # HTML samples of binance exchange documentation
├── specs/ # Generated OpenAPI specifications
├── templates/ # Template files for spec generation
├── go.mod # Go module definition
├── go.sum # Go module dependencies checksum
└── Makefile # Build and development commands
Key directories and their purposes:
cmd/
: Contains the main application entry pointsinternal/
: Houses the core application logicconfig/
: Manages application configurationexchange/
: Exchange-specific implementations and parsersgenerator/
: OpenAPI specification generation logicparser/
: Documentation parsing and extraction
configs/
: Configuration files for exchange URLs and settingsgenerator-configs/
: OpenAPI Generator-specific configurationshistory/
: Tracks version history of generated specificationssamples/
: Contains webpage samples of exchange documentationspecs/
: Stores generated OpenAPI specificationstemplates/
: Template files used in SDK generation
- Go 1.21 or higher
- Git
- Clone the repository:
git clone https://github.com/openxapi/openxapi.git
cd openxapi
- Install dependencies:
go mod download
- Build the project:
make build
- Configure exchange API documentation URLs in
configs/config.yaml
- Run the OpenAPI specification generator:
./openxapi
NOTE: This command will scrape the exchange's website and parse the API documentation from the website, so it may take a while to complete. Only run this command when you want to use the latest API documentation instead of the sample files.
The generated OpenAPI specification will be saved in specs/
directory.
The program can save API documentation to sample files and use them for regenerate the OpenAPI specification offline by default, that said, you don't need to access the HTTP API documentation online, this is the recommended way to generate the OpenAPI specification after the first generation:
./openxapi
Or simply use make
command:
make generate-spec EXCHANGE=binance
If you find there are some issues on the generated OpenAPI specification, please check with the exchange's official API documentation, because we try to parse the API documentation from the exchange's website automatically, there are some API documentation that is not structured well, so we need to maintain the OpenAPI specification manually.
Please follow the steps below to mannually update the OpenAPI specification:
- Find the OpenAPI specification for an exchange in
specs/
directory, for example,specs/binance/openapi/spot/delete_api_v3_openOrders.yaml
. - Add the endpoint to the
protected_endpoints
section inconfigs/exchanges/binance/restapi.yaml
, this will make sure the endpoint will be ignored by the automatic generation. - Update the OpenAPI specification in
specs/binance/openapi/spot/delete_api_v3_openOrders.yaml
. - Regenerate the OpenAPI specification by the steps in Generate OpenAPI Specification section.
We use OpenAPI Generator to generate SDKs for OpenAPI Specification.
Following is an example of generating Go SDK for Binance Spot REST API:
make generate-sdk EXCHANGE=binance LANGUAGE=go OUTPUT_DIR=../binance-go
- Supported languages:
go
,python
,js
,rust
- Supported exchanges:
binance
If you need to update the genereated SDK code, do not edit the generated code directly. Instead, update the templates in templates/
and regenerate the SDK code.
After updating the templates, you can regenerate the SDK code by the steps in Generate SDKs for OpenAPI Specification section.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Make sure to make format && make test
before committing your changes.
This project is licensed under the MIT License - see the LICENSE file for details.