Giter Club home page Giter Club logo

swagger_codegen's Introduction

Swagger codegen for Python

Continuous Integration

Installation

pip install swagger-codegen

Swagger version

Currently, only OpenApi 3.x (aka Swagger 3) is supported.

Usage example

# Generate Petstore Api client using 'petstore' package name.
swagger_codegen generate https://petstore3.swagger.io/api/v3/openapi.json petstore

python

Python 3.8.1 (default, Jan 23 2020, 13:58:52) 
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> from petstore import new_client, Configuration
>>> from swagger_codegen.api.adapter.requests import RequestsAdapter
>>> from petstore.apis.user.createUser import User
>>> client = new_client(RequestsAdapter(), Configuration(host="http://petstore3.swagger.io"))
>>> pets = client.pet.findPetsByStatus()
>>> print(pets)
[Pet(category=Category(id=1, name='Dogs'), id=69, name='aHldog', photoUrls=['string'], status='available',...]

You can see example source code for PetStore Api in example directory of a project.

You can test example client with following command:

# Run from project directory.
python -m example.petstore_example 

Code generators (also known as renderers)

There are two code generator strategies in project:

  1. Render client as usual python package via PackageRenderer
  2. Render client as installable python package via InstallablePackageRenderer

You can choose what renderer to use by specifying renderer key in .swagger-codegen.toml file. Please see .swagger-codegen.toml.example for allowed values.

Known issues

  • Content of generated files differs run-to-run because each time functions or data transfer objects ordered differently. Functionally clients stay the same, but each time the code is generated there are a large diff generated by git.
  • Not fully Openapi compliant: the project was built to fulfill my personal needs: a support for FastAPI-generated schemas, and I needed this feature quickly, that is why there are too many large dependencies (schemathesis) and incompatibilities. Anyway, I'm looking forward to fixing this issues by time.
  • There are may be delays in reaction to issues due to small amount of free time (however PR's with tests are merged asap).

Work in progress

Though library gives nice results for generated API, it is still in development. Some tests are missing. API is a subject to change until stable release.

Anyway backward compatibility will be kept as much as possible.

The code is not optimized yet and mostly dirty because the project was born as a holiday prototype.

Also example directory may be out of sync with actual generated code.

Contributors

You can see all people who helped this project at the contributors page

swagger_codegen's People

Contributors

asyncee avatar coderfromhere avatar dependabot[bot] avatar livestalker avatar ticosax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

swagger_codegen's Issues

full swagger json

'''
{
"openapi": "3.0.0",
"info": {
"title": "Client Portal Web API",
"description": "Production version of the Client Portal Web API",
"version": "1.0.0"
},
"paths": {
"/iserver/account/trades": {
"get": {
"summary": "List of Trades for the selected account",
"description": "Returns a list of trades for the currently selected account for current day and six previous days.",
"tags": [
"Trades"
],
"responses": {
"200": {
"description": "An array of trades",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/trade"
}
}
}
}
}
}
}
},
"/iserver/accounts": {
"get": {
"summary": "Brokerage Accounts",
"description": "Returns a list of accounts the user has trading access to, their respective aliases and the currently selected account. Note this endpoint must be called before modifying an order or querying open orders.",
"tags": [
"Account"
],
"responses": {
"200": {
"description": "An array of accounts",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"accounts": {
"type": "array",
"items": {
"type": "string"
},
"description": "Unique account id"
},
"aliases": {
"type": "object",
"description": "Account Id and its alias"
},
"selectedAccount": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/iserver/account": {
"post": {
"summary": "Updates currently selected account to the provided account",
"description": "If an user has multiple accounts, and user wants to get orders, trades, etc. of an account other than currently selected account, then user can update the currently selected account using this API and then can fetch required information for the newly updated account.",
"tags": [
"Account"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/set-account"
}
}
},
"description": "account id",
"required": true
},
"responses": {
"200": {
"description": "an object containing updated account ID",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"set": {
"type": "boolean"
},
"acctId": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/iserver/account/orders": {
"get": {
"summary": "Live Orders",
"description": "The end-point is meant to be used in polling mode, e.g. requesting every x seconds.\nThe response will contain two objects, one is notification, the other is orders. \nOrders is the list of orders (cancelled, filled, submitted) with activity in the current day. \nNotifications contains information about execute orders as they happen, see status field.\n",
"tags": [
"Order"
],
"responses": {
"200": {
"description": "An object contains two arrays",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"orders": {
"type": "array",
"items": {
"$ref": "#/components/schemas/order"
}
},
"notifications": {
"type": "array",
"items": {
"type": "object",
"description": "contains notifications for different status of orders, the data structure is same to orders"
}
}
}
}
}
}
}
}
}
},
"/iserver/account/{accountId}/order": {
"post": {
"summary": "Place Order",
"description": "Please note here, sometimes this end-point alone can't make sure you submit the order successfully,\nyou could receive some questions in the response, you have to to answer them in order to submit the order\nsuccessfully. You can use "/iserver/reply/{replyid}" end-point to answer questions\n",
"tags": [
"Order"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/order-request"
}
}
},
"description": "order request info",
"required": true
},
"responses": {
"200": {
"description": "returns an array",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"message": {
"type": "array",
"description": "Please note here, if the message is a question, you have to reply to question in order to submit\nthe order successfully. See more in the "/iserver/reply/{replyid}" end-point.\n",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
},
"/iserver/account/{accountId}/orders": {
"post": {
"summary": "Place Orders (Support bracket orders)",
"description": "You can pass a list of orders here\n",
"tags": [
"Order"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"orders": {
"type": "array",
"description": "Notes for bracket orders: 1. Children orders will not have its own "cOID", so please donot pass "cOID"\nparameter in child order.Instead, they will have a "parentId" which must be equal to "cOID" of parent.\n2. When you cancel a parent order, it will cancel all bracket orders, when you cancel one child order,\nit will also cancel its sibling order.\n",
"items": {
"$ref": "#/components/schemas/order-request"
}
}
}
}
}
},
"description": "order request info",
"required": true
},
"responses": {
"200": {
"description": "returns an array",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"message": {
"type": "array",
"description": "Please note here, if the message is a question, you have to reply to question in order to submit\nthe order successfully. See more in the "/iserver/reply/{replyid}" end-point.\n",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
},
"/iserver/reply/{replyid}": {
"post": {
"summary": "Place Order Reply",
"description": "Reply to questions when placing orders and submit orders",
"tags": [
"Order"
],
"parameters": [
{
"name": "replyid",
"in": "path",
"required": true,
"description": "Please use the "id" from the response of "Place Order" end-point",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"confirmed": {
"description": "answer to question, true means yes, false means no",
"type": "boolean"
}
}
}
}
},
"description": "Answer to question",
"required": true
},
"responses": {
"200": {
"description": "Order is submitted successfully, returns an array contains one object",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"order_id": {
"type": "string"
},
"order_status": {
"type": "string"
},
"local_order_id": {
"type": "string"
}
}
}
}
}
}
},
"400": {
"description": "When you send "confirmed-false" in the request, you will receive this",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"description": "for example-order not confirmed",
"type": "string"
},
"statusCode": {
"type": "integer"
}
}
}
}
}
}
}
}
},
"/iserver/account/{accountId}/order/whatif": {
"post": {
"summary": "Preview Order",
"description": "This end-point allows you to preview order without actually submitting the order and you can get\ncommission information in the response.\n",
"tags": [
"Order"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/order-request"
}
}
},
"description": "order info",
"required": true
},
"responses": {
"200": {
"description": "returns an object",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"amount": {
"type": "object",
"properties": {
"amount": {
"type": "string",
"description": "for example 23,000 USD"
},
"commission": {
"type": "string",
"description": "for example 1.1 ... 1.2 USD"
},
"total": {
"type": "string"
}
}
},
"equity": {
"type": "object",
"properties": {
"current": {
"type": "string"
},
"change": {
"type": "string"
},
"after": {
"type": "string"
}
}
},
"initial": {
"type": "object",
"properties": {
"current": {
"type": "string"
},
"change": {
"type": "string"
},
"after": {
"type": "string"
}
}
},
"maintenance": {
"type": "object",
"properties": {
"current": {
"type": "string"
},
"change": {
"type": "string"
},
"after": {
"type": "string"
}
}
},
"warn": {
"type": "string"
},
"error": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/iserver/account/{accountId}/order/{origCustomerOrderId}": {
"post": {
"summary": "Modify Order",
"description": "Modifies an open order. The /iserver/accounts endpoint must first be called.",
"tags": [
"Order"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
},
{
"in": "path",
"name": "origCustomerOrderId",
"description": "Customer OrderId",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/modify-order"
}
}
},
"description": "modify-order request",
"required": true
},
"responses": {
"200": {
"description": "returns an array",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"order_id": {
"type": "string"
},
"local_order_id": {
"type": "string"
},
"order_status": {
"type": "string"
}
}
}
}
}
}
}
}
},
"delete": {
"summary": "Delete Order",
"tags": [
"Order"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
},
{
"in": "path",
"name": "origCustomerOrderId",
"description": "Customer OrderId",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "returns an array",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"order_id": {
"type": "string"
},
"local_order_id": {
"type": "string"
},
"order_status": {
"type": "string"
}
}
}
}
}
}
}
}
}
},
"/iserver/marketdata/snapshot": {
"get": {
"summary": "Market Data",
"description": "Get Market Data for the given conid(s). The end-point will return by default bid, ask, last, change, change pct, close, listing exchange.\nSee response fields for a list of available fields that can be request via fields argument.\nThe endpoint /iserver/accounts should be called prior to /iserver/marketdata/snapshot.\nTo receive all available fields the /snapshot endpoint will need to be called several times.\n",
"tags": [
"Market_Data"
],
"parameters": [
{
"in": "query",
"name": "conids",
"description": "list of conids separated by comma",
"required": true,
"schema": {
"type": "string"
}
},
{
"in": "query",
"name": "since",
"description": "time period since which updates are required. uses epoch time with milliseconds.",
"required": false,
"schema": {
"type": "integer"
}
},
{
"in": "query",
"name": "fields",
"description": "list of fields separated by comma",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Returns an array of objects",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"31": {
"type": "string",
"description": "Last Price"
},
"55": {
"type": "string",
"description": "Symbol"
},
"58": {
"type": "string",
"description": "Text"
},
"70": {
"type": "string",
"description": "High"
},
"71": {
"type": "string",
"description": "Low"
},
"72": {
"type": "string",
"description": "Position"
},
"73": {
"type": "string",
"description": "Market Value"
},
"74": {
"type": "string",
"description": "Average Price"
},
"75": {
"description": "Unrealized PnL",
"type": "string"
},
"76": {
"type": "string"
},
"77": {
"type": "string"
},
"78": {
"type": "string"
},
"82": {
"type": "string",
"description": "Change Price"
},
"83": {
"type": "string",
"description": "Change Percent"
},
"84": {
"type": "string",
"description": "Bid Price"
},
"85": {
"type": "string",
"description": "Ask Size"
},
"86": {
"type": "string",
"description": "Ask Price"
},
"87": {
"type": "string",
"description": "Volume"
},
"88": {
"type": "string",
"description": "Bid Size"
},
"6004": {
"type": "string",
"description": "Exchange"
},
"6008": {
"type": "string",
"description": "Conid"
},
"6070": {
"type": "string",
"description": "Security Type"
},
"6072": {
"type": "string",
"description": "Months"
},
"6073": {
"type": "string",
"description": "Regular Expiry"
},
"6119": {
"type": "string"
},
"6457": {
"type": "string",
"description": "Underlying Conid. Use /trsrv/secdef to get more information about the security"
},
"6509": {
"type": "string",
"description": "Market Data Availability. The field may contain two chars. The first char is the primary code: R = Realtime, D = Delayed,\nZ = Frozen, Y = Frozen Delayed. The second char is the secondary code: P = Snapshot Available, p = Consolidated.\n"
},
"7051": {
"type": "string"
},
"7094": {
"type": "string",
"description": "Conid + Exchange"
},
"7219": {
"type": "string",
"description": "Contract Description"
},
"7220": {
"type": "string",
"description": "Contract Description"
},
"7221": {
"type": "string",
"description": "Listing Exchange"
},
"7280": {
"type": "string",
"description": "Industry"
},
"7281": {
"type": "string",
"description": "Category"
},
"7282": {
"type": "string",
"description": "Average Daily Volume"
},
"7284": {
"type": "string",
"description": "Historic Volume (30d)"
},
"7285": {
"type": "string",
"description": "Put/Call Ratio"
},
"7286": {
"type": "string",
"description": "Dividend Amount"
},
"7287": {
"type": "string",
"description": "Dividend Yield %"
},
"7288": {
"type": "string",
"description": "Ex-date of the dividend"
},
"7289": {
"type": "string",
"description": "Market Cap"
},
"7290": {
"type": "string",
"description": "P/E"
},
"7291": {
"type": "string",
"description": "EPS"
},
"7292": {
"type": "string",
"description": "Cost Basis"
},
"7293": {
"type": "string",
"description": "52 Week High"
},
"7294": {
"type": "string",
"description": "52 Week Low"
},
"7295": {
"type": "string",
"description": "Open Price"
},
"7296": {
"type": "string",
"description": "Close Price"
},
"7633": {
"type": "string",
"description": "Implied volatility of the option"
},
"server_id": {
"type": "string"
},
"conid": {
"type": "integer"
},
"_updated": {
"type": "integer"
}
}
}
}
}
}
},
"400": {
"description": "sent when accounts are not queried before sending this request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"statusCode": {
"type": "integer"
}
}
}
}
}
}
}
}
},
"/iserver/marketdata/history": {
"get": {
"summary": "Market Data History",
"description": "Get history of market Data for the given conid, length of data is controlled by period and bar. e.g. 1y period with bar =1w returns 52 data points",
"tags": [
"Market_Data"
],
"parameters": [
{
"in": "query",
"name": "conid",
"description": "contract id",
"required": true,
"schema": {
"type": "string"
}
},
{
"in": "query",
"name": "period",
"description": "time period-- 1d,1w,1m,1y",
"required": true,
"schema": {
"type": "string"
}
},
{
"in": "query",
"name": "bar",
"description": "possible value-- 5min,1h,1w",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Returns an object",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/history-data"
}
}
}
}
}
}
},
"/iserver/contract/{conid}/info": {
"get": {
"summary": "Contract Info",
"description": "get contract details, you can use this to prefill your order before you submit an order",
"tags": [
"Contract"
],
"parameters": [
{
"name": "conid",
"in": "path",
"required": true,
"description": "contract id",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "returns an object",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/contract"
}
}
}
}
}
}
},
"/iserver/secdef/search": {
"post": {
"summary": "Search by symbol or name",
"tags": [
"Contract"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"symbol"
],
"properties": {
"symbol": {
"type": "string",
"description": "symbol or name to be searched"
},
"name": {
"type": "boolean",
"description": "should be true if the search is to be performed by name. false by default."
},
"secType": {
"type": "string",
"description": "If search is done by name, only the assets provided in this field will be returned. Currently, only STK is supported."
}
}
}
}
},
"description": "symbol or name to be searched",
"required": true
},
"responses": {
"200": {
"description": "returns an array of results",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"conid": {
"type": "integer"
},
"companyHeader": {
"type": "string"
},
"companyName": {
"type": "string"
},
"symbol": {
"type": "string"
},
"description": {
"type": "string"
},
"opt": {
"type": "string"
},
"war": {
"type": "string"
},
"sections": {
"type": "array",
"items": {
"type": "object"
}
}
}
}
}
}
}
},
"500": {
"description": "error while processing the request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/iserver/scanner/params": {
"get": {
"summary": "get lists of available scanners",
"description": "Returns an object contains four lists contain all parameters for scanners",
"tags": [
"Scanner"
],
"responses": {
"200": {
"description": "An object contains lists",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"scan_type_list": {
"type": "array",
"items": {
"type": "object",
"properties": {
"display_name": {
"type": "string"
},
"code": {
"type": "string"
},
"instruments": {
"type": "array",
"items": {
"type": "string",
"description": "type of instrument"
}
}
}
}
},
"instrument_list": {
"type": "array",
"items": {
"type": "object",
"properties": {
"display_name": {
"type": "string"
},
"type": {
"type": "string"
},
"filters": {
"type": "array",
"items": {
"type": "string",
"description": "code of filter"
}
}
}
}
},
"filter_list": {
"type": "array",
"items": {
"type": "object",
"properties": {
"group": {
"type": "string"
},
"display_name": {
"type": "string"
},
"code": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
},
"location_tree": {
"type": "array",
"items": {
"type": "object",
"properties": {
"display_name": {
"type": "string"
},
"type": {
"type": "string"
},
"locations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"display_name": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"/iserver/scanner/run": {
"post": {
"summary": "run scanner to get a list of contracts",
"tags": [
"Scanner"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/scanner-params"
}
}
},
"description": "modify-order request",
"required": true
},
"responses": {
"200": {
"description": "returns an array",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"server_id": {
"type": "string"
},
"column_name": {
"type": "string"
},
"symbol": {
"type": "string"
},
"conidex": {
"type": "string"
},
"con_id": {
"type": "number"
},
"available_chart_periods": {
"type": "string"
},
"company_name": {
"type": "string"
},
"contract_description_1": {
"type": "string"
},
"listing_exchange": {
"type": "string"
},
"sec_type": {
"type": "string"
}
}
}
}
}
}
}
}
}
},
"/iserver/account/pnl/partitioned": {
"get": {
"summary": "PnL for the selected account",
"description": "Returns an object containing PnLfor the selected account and its models (if any).",
"tags": [
"PnL",
"Account"
],
"responses": {
"200": {
"description": "An object containing account and model(s) pnl",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"acctId": {
"type": "object"
}
}
}
}
}
}
}
}
},
"/sso/validate": {
"get": {
"summary": "Validate SSO",
"description": "Validates the current session for the SSO user",
"tags": [
"Session"
],
"responses": {
"200": {
"description": "An Object",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"LOGIN_TYPE": {
"description": "1 for Live, 2 for Paper",
"type": "number"
},
"USER_NAME": {
"description": "Username",
"type": "string"
},
"USER_ID": {
"description": "User ID",
"type": "number"
},
"expire": {
"description": "Time in milliseconds until session expires. Caller needs to call the again to re-validate session",
"type": "number"
},
"RESULT": {
"description": "true if session was validated; false if not.",
"type": "boolean"
},
"AUTH_TIME": {
"description": "Time of session validation",
"type": "number"
}
}
}
}
}
},
"401": {
"description": "Authentication failed"
},
"500": {
"description": "System failed"
}
}
}
},
"/portfolio/accounts": {
"get": {
"summary": "Portfolio Accounts",
"description": "In non-tiered account structures, returns a list of accounts for which the user can view position and account information. This endpoint must be called prior to calling other /portfolio endpoints for those accounts. For querying a list of accounts which the user can trade, see /iserver/accounts. For a list of subaccounts in tiered account structures (e.g. financial advisor or ibroker accounts) see /portfolio/subaccounts.",
"tags": [
"Account",
"Portfolio"
],
"responses": {
"200": {
"description": "An array",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/accounts"
}
}
}
}
}
}
},
"/portfolio/subaccounts": {
"get": {
"summary": "List of Sub-Accounts",
"description": "Used in tiered account structures (such as financial advisor and ibroker accounts) to return a list of sub-accounts for which the user can view position and account-related information. This endpoint must be called prior to calling other /portfolio endpoints for those subaccounts. To query a list of accounts the user can trade, see /iserver/accounts.",
"tags": [
"Account",
"Portfolio"
],
"responses": {
"200": {
"description": "An array",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/account"
}
}
}
}
}
}
},
"/portfolio/{accountId}/meta": {
"get": {
"summary": "Account Information",
"description": "Account information related to account Id /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.",
"tags": [
"Account",
"Portfolio"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "An object",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/accounts"
}
}
}
}
}
}
},
"/portfolio/{accountId}/allocation": {
"get": {
"summary": "Account Allocation",
"description": "Information about the account's portfolio allocation by Asset Class, Industry and Category. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.",
"tags": [
"Portfolio"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "returns an object of three different allocations",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/allocation"
}
}
}
}
}
}
},
"/portfolio/allocation": {
"post": {
"summary": "Account Alloction (All Accounts)",
"description": "Similar to /portfolio/{accountId}/allocation but returns a consolidated view of of all the accounts returned by /portfolio/accounts. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.",
"tags": [
"Portfolio"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"acctIds": {
"type": "array",
"items": {
"type": "string",
"description": "account id"
}
}
}
}
}
},
"description": "accounts info",
"required": true
},
"responses": {
"200": {
"description": "returns an object of three different allocations",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/allocation"
}
}
}
}
}
}
},
"/portfolio/{accountId}/positions/{pageId}": {
"get": {
"summary": "Portfolio Positions",
"description": "Returns a list of positions for the given account. The endpoint supports paging, page's default size is 30 positions. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.",
"tags": [
"Portfolio"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
},
{
"name": "pageId",
"in": "path",
"required": true,
"description": "page id",
"schema": {
"type": "string",
"default": "0"
}
},
{
"name": "model",
"in": "query",
"description": "optional",
"schema": {
"type": "string"
}
},
{
"name": "sort",
"in": "query",
"description": "declare the table to be sorted by which column",
"schema": {
"type": "string"
}
},
{
"name": "direction",
"in": "query",
"description": "in which order, a means ascending - d means descending",
"schema": {
"type": "string"
}
},
{
"name": "period",
"in": "query",
"description": "period for pnl column, can be 1D, 7D, 1M...",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "returns a list of positions in the portfolio",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/position"
}
}
}
}
}
}
},
"/portfolio/{accountId}/position/{conid}": {
"get": {
"summary": "Position by Conid",
"description": "Returns a list of all positions matching the conid. For portfolio models the conid could be in more than one model, returning an array with the name of the model it belongs to. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.",
"tags": [
"Portfolio"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
},
{
"name": "conid",
"in": "path",
"required": true,
"description": "contract id",
"schema": {
"type": "integer"
}
}
],
"responses": {
"200": {
"description": "returns a list containing only one position for the conid",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/position"
}
}
}
}
}
}
},
"/portfolio/{accountId}/positions/invalidate": {
"post": {
"summary": "Invalidates the backend cache of the Portfolio",
"tags": [
"Portfolio"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "200 means successful",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/portfolio/{accountId}/summary": {
"get": {
"summary": "Account Summary",
"description": "Returns information about margin, cash balances and other information related to specified account. See also /portfolio/{accountId}/ledger. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.",
"tags": [
"Account",
"Portfolio"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "returns an object containing account summary. The object contains multiple properties. A property is sufficed with -c if its provides commodity value, -s if it provides security value and -c if its UKL segment value",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"accountready": {
"$ref": "#/components/schemas/summary"
},
"accounttype": {
"$ref": "#/components/schemas/summary"
},
"accruedcash": {
"$ref": "#/components/schemas/summary"
},
"accruedcash-c": {
"$ref": "#/components/schemas/summary"
},
"accruedcash-f": {
"$ref": "#/components/schemas/summary"
},
"accruedcash-s": {
"$ref": "#/components/schemas/summary"
},
"accrueddividend": {
"$ref": "#/components/schemas/summary"
},
"accrueddividend-c": {
"$ref": "#/components/schemas/summary"
},
"accrueddividend-f": {
"$ref": "#/components/schemas/summary"
},
"accrueddividend-s": {
"$ref": "#/components/schemas/summary"
},
"availablefunds": {
"$ref": "#/components/schemas/summary"
},
"availablefunds-c": {
"$ref": "#/components/schemas/summary"
},
"availablefunds-f": {
"$ref": "#/components/schemas/summary"
},
"availablefunds-s": {
"$ref": "#/components/schemas/summary"
},
"billable": {
"$ref": "#/components/schemas/summary"
},
"billable-c": {
"$ref": "#/components/schemas/summary"
},
"billable-f": {
"$ref": "#/components/schemas/summary"
},
"billable-s": {
"$ref": "#/components/schemas/summary"
},
"buyingpower": {
"$ref": "#/components/schemas/summary"
},
"cushion": {
"$ref": "#/components/schemas/summary"
},
"daytradesremaining": {
"$ref": "#/components/schemas/summary"
},
"daytradesremainingt+1": {
"$ref": "#/components/schemas/summary"
},
"daytradesremainingt+2": {
"$ref": "#/components/schemas/summary"
},
"daytradesremainingt+3": {
"$ref": "#/components/schemas/summary"
},
"daytradesremainingt+4": {
"$ref": "#/components/schemas/summary"
},
"equitywithloanvalue": {
"$ref": "#/components/schemas/summary"
},
"equitywithloanvalue-c": {
"$ref": "#/components/schemas/summary"
},
"equitywithloanvalue-f": {
"$ref": "#/components/schemas/summary"
},
"equitywithloanvalue-s": {
"$ref": "#/components/schemas/summary"
},
"excessliquidity": {
"$ref": "#/components/schemas/summary"
},
"excessliquidity-c": {
"$ref": "#/components/schemas/summary"
},
"excessliquidity-f": {
"$ref": "#/components/schemas/summary"
},
"excessliquidity-s": {
"$ref": "#/components/schemas/summary"
},
"fullavailablefunds": {
"$ref": "#/components/schemas/summary"
},
"fullavailablefunds-c": {
"$ref": "#/components/schemas/summary"
},
"fullavailablefunds-f": {
"$ref": "#/components/schemas/summary"
},
"fullavailablefunds-s": {
"$ref": "#/components/schemas/summary"
},
"fullexcessliquidity": {
"$ref": "#/components/schemas/summary"
},
"fullexcessliquidity-c": {
"$ref": "#/components/schemas/summary"
},
"fullexcessliquidity-f": {
"$ref": "#/components/schemas/summary"
},
"fullexcessliquidity-s": {
"$ref": "#/components/schemas/summary"
},
"fullinitmarginreq": {
"$ref": "#/components/schemas/summary"
},
"fullinitmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"fullinitmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"fullinitmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"fullmaintmarginreq": {
"$ref": "#/components/schemas/summary"
},
"fullmaintmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"fullmaintmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"fullmaintmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"grosspositionvalue": {
"$ref": "#/components/schemas/summary"
},
"grosspositionvalue-c": {
"$ref": "#/components/schemas/summary"
},
"grosspositionvalue-f": {
"$ref": "#/components/schemas/summary"
},
"grosspositionvalue-s": {
"$ref": "#/components/schemas/summary"
},
"guarantee": {
"$ref": "#/components/schemas/summary"
},
"guarantee-c": {
"$ref": "#/components/schemas/summary"
},
"guarantee-f": {
"$ref": "#/components/schemas/summary"
},
"guarantee-s": {
"$ref": "#/components/schemas/summary"
},
"highestseverity": {
"$ref": "#/components/schemas/summary"
},
"highestseverity-c": {
"$ref": "#/components/schemas/summary"
},
"highestseverity-f": {
"$ref": "#/components/schemas/summary"
},
"highestseverity-s": {
"$ref": "#/components/schemas/summary"
},
"indianstockhaircut": {
"$ref": "#/components/schemas/summary"
},
"indianstockhaircut-c": {
"$ref": "#/components/schemas/summary"
},
"indianstockhaircut-f": {
"$ref": "#/components/schemas/summary"
},
"indianstockhaircut-s": {
"$ref": "#/components/schemas/summary"
},
"initmarginreq": {
"$ref": "#/components/schemas/summary"
},
"initmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"initmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"initmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"leverage": {
"$ref": "#/components/schemas/summary"
},
"leverage-c": {
"$ref": "#/components/schemas/summary"
},
"leverage-f": {
"$ref": "#/components/schemas/summary"
},
"leverage-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadavailablefunds": {
"$ref": "#/components/schemas/summary"
},
"lookaheadavailablefunds-c": {
"$ref": "#/components/schemas/summary"
},
"lookaheadavailablefunds-f": {
"$ref": "#/components/schemas/summary"
},
"lookaheadavailablefunds-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadexcessliquidity": {
"$ref": "#/components/schemas/summary"
},
"lookaheadexcessliquidity-c": {
"$ref": "#/components/schemas/summary"
},
"lookaheadexcessliquidity-f": {
"$ref": "#/components/schemas/summary"
},
"lookaheadexcessliquidity-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadinitmarginreq": {
"$ref": "#/components/schemas/summary"
},
"lookaheadinitmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"lookaheadinitmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"lookaheadinitmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadmaintmarginreq": {
"$ref": "#/components/schemas/summary"
},
"lookaheadmaintmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"lookaheadmaintmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"lookaheadmaintmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadnextchange": {
"$ref": "#/components/schemas/summary"
},
"maintmarginreq": {
"$ref": "#/components/schemas/summary"
},
"maintmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"maintmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"maintmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"netliquidation": {
"$ref": "#/components/schemas/summary"
},
"netliquidation-c": {
"$ref": "#/components/schemas/summary"
},
"netliquidation-f": {
"$ref": "#/components/schemas/summary"
},
"netliquidation-s": {
"$ref": "#/components/schemas/summary"
},
"netliquidationuncertainty": {
"$ref": "#/components/schemas/summary"
},
"nlvandmargininreview": {
"$ref": "#/components/schemas/summary"
},
"pasharesvalue": {
"$ref": "#/components/schemas/summary"
},
"pasharesvalue-c": {
"$ref": "#/components/schemas/summary"
},
"pasharesvalue-f": {
"$ref": "#/components/schemas/summary"
},
"pasharesvalue-s": {
"$ref": "#/components/schemas/summary"
},
"postexpirationexcess": {
"$ref": "#/components/schemas/summary"
},
"postexpirationexcess-c": {
"$ref": "#/components/schemas/summary"
},
"postexpirationexcess-f": {
"$ref": "#/components/schemas/summary"
},
"postexpirationexcess-s": {
"$ref": "#/components/schemas/summary"
},
"postexpirationmargin": {
"$ref": "#/components/schemas/summary"
},
"postexpirationmargin-c": {
"$ref": "#/components/schemas/summary"
},
"postexpirationmargin-f": {
"$ref": "#/components/schemas/summary"
},
"postexpirationmargin-s": {
"$ref": "#/components/schemas/summary"
},
"previousdayequitywithloanvalue": {
"$ref": "#/components/schemas/summary"
},
"previousdayequitywithloanvalue-c": {
"$ref": "#/components/schemas/summary"
},
"previousdayequitywithloanvalue-f": {
"$ref": "#/components/schemas/summary"
},
"previousdayequitywithloanvalue-s": {
"$ref": "#/components/schemas/summary"
},
"segmenttitle-c": {
"$ref": "#/components/schemas/summary"
},
"segmenttitle-f": {
"$ref": "#/components/schemas/summary"
},
"segmenttitle-s": {
"$ref": "#/components/schemas/summary"
},
"totalcashvalue": {
"$ref": "#/components/schemas/summary"
},
"totalcashvalue-c": {
"$ref": "#/components/schemas/summary"
},
"totalcashvalue-f": {
"$ref": "#/components/schemas/summary"
},
"totalcashvalue-s": {
"$ref": "#/components/schemas/summary"
},
"totaldebitcardpendingcharges": {
"$ref": "#/components/schemas/summary"
},
"totaldebitcardpendingcharges-c": {
"$ref": "#/components/schemas/summary"
},
"totaldebitcardpendingcharges-f": {
"$ref": "#/components/schemas/summary"
},
"totaldebitcardpendingcharges-s": {
"$ref": "#/components/schemas/summary"
},
"tradingtype-f": {
"$ref": "#/components/schemas/summary"
},
"tradingtype-s": {
"$ref": "#/components/schemas/summary"
}
}
}
}
}
}
}
}
},
"/portfolio/{accountId}/ledger": {
"get": {
"summary": "Account Ledger",
"description": "Information regarding settled cash, cash balances, etc. in the account's base currency and any other cash balances hold in other currencies. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint. The list of supported currencies is available at https://www.interactivebrokers.com/en/index.php?f=3185.",
"tags": [
"Account",
"Portfolio"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "200 means successful",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"BASE": {
"$ref": "#/components/schemas/ledger"
}
}
}
}
}
}
}
}
},
"/portfolio/positions/{conid}": {
"get": {
"summary": "Positions by Conid",
"description": "Returns an object of all positions matching the conid for all the selected accounts. For portfolio models the conid could be in more than one model, returning an array with the name of the model it belongs to. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.",
"tags": [
"Portfolio"
],
"parameters": [
{
"name": "conid",
"in": "path",
"required": true,
"description": "contract id",
"schema": {
"type": "integer"
}
}
],
"responses": {
"200": {
"description": "returns an object containing account and its position information",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"ACCTID": {
"$ref": "#/components/schemas/position"
}
}
}
}
}
}
}
}
},
"/tickle": {
"post": {
"summary": "Ping the server to keep the session open",
"description": "If the gateway has not received any requests for several minutes an open session will automatically timeout. The tickle endpoint pings the server to prevent the session from ending.",
"tags": [
"Session"
],
"responses": {
"200": {
"description": "confirms session is open"
}
}
}
},
"/logout": {
"post": {
"summary": "Ends the current session",
"description": "Logs the user out of the gateway session. Any further activity requires re-authentication.",
"tags": [
"Session"
],
"responses": {
"200": {
"description": "returned status indicates if user is logged in",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"confirmed": {
"description": "true means username is still logged in, false means it is not",
"type": "boolean"
}
}
}
}
}
}
}
}
},
"/pa/performance": {
"post": {
"summary": "Account Performance",
"description": "Returns the performance (MTM) for the given accounts, if more than one account is passed, the result is consolidated.",
"tags": [
"PortfolioAnalyst"
],
"requestBody": {
"$ref": "#/components/requestBodies/Body"
},
"responses": {
"200": {
"description": "returns an object",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/performance"
}
}
}
}
}
}
},
"/pa/summary": {
"post": {
"summary": "Account Balance's Summary",
"description": "Returns a summary of all account balances for the given accounts, if more than one account is passed, the result is consolidated.",
"tags": [
"PortfolioAnalyst"
],
"requestBody": {
"$ref": "#/components/requestBodies/Body"
},
"responses": {
"200": {
"description": "returns an object",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/summary"
}
}
}
}
}
}
},
"/trsrv/secdef": {
"post": {
"summary": "Secdef by Conid",
"description": "Returns a list of security definitions for the given conids",
"tags": [
"Contract"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"conids": {
"type": "array",
"items": {
"type": "integer",
"description": "contract id"
}
}
}
}
}
},
"description": "request body",
"required": true
},
"responses": {
"200": {
"description": "returns an array of secdef info",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/secdef"
}
}
}
}
}
}
},
"/trsrv/futures": {
"get": {
"summary": "Security Futures by Symbol",
"description": "Returns a list of non-expired future contracts for given symbol(s)",
"tags": [
"Contract"
],
"parameters": [
{
"in": "query",
"name": "symbols",
"description": "list of case-sensitive symbols separated by comma",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "returns an object with symbol and and array of its future contracts",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"symbol": {
"$ref": "#/components/schemas/futures"
}
}
}
}
}
},
"500": {
"description": "error while processing the request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/ibcust/entity/info": {
"get": {
"summary": "IBCust Entity Info",
"description": "Returns Applicant Id with all owner related entities",
"tags": [
"IBCust"
],
"responses": {
"200": {
"description": "Search result",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"applicantId": {
"type": "number"
},
"entities": {
"type": "array",
"items": {
"type": "object",
"properties": {
"canTrade": {
"type": "boolean"
},
"canSign": {
"type": "boolean"
},
"type": {
"type": "string"
},
"name": {
"type": "object",
"properties": {
"salutation": {
"type": "string"
},
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
}
}
},
"address": {
"type": "object",
"properties": {
"street": {
"type": "string"
},
"street2": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string"
},
"postalCode": {
"type": "string"
},
"country": {
"type": "string"
},
"countryCode": {
"type": "string"
},
"compact": {
"type": "string"
}
}
},
"identDocs": {
"type": "array",
"items": {
"type": "object",
"items": {
"type": "object",
"properties": {
"country": {
"type": "string"
},
"state": {
"type": "string"
},
"type": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"/fyi/unreadnumber": {
"get": {
"summary": "Get unread number of fyis",
"tags": [
"FYI"
],
"responses": {
"200": {
"description": "An object",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"BN": {
"type": "integer",
"description": "unread number"
}
}
}
}
}
}
}
}
},
"/fyi/settings": {
"get": {
"summary": "Get a list of subscriptions",
"tags": [
"FYI"
],
"description": "return the current choices of subscriptions, we can toggle the option\n",
"responses": {
"200": {
"description": "An array",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"A": {
"type": "integer",
"description": "optional, if A doesn't exist, it means user can't toggle this option. 0-off, 1-on."
},
"FC": {
"type": "string",
"description": "fyi code"
},
"H": {
"type": "integer",
"description": "disclaimer read, 1 = yes, = 0 no."
},
"FD": {
"type": "string",
"description": "detailed description"
},
"FN": {
"type": "string",
"description": "title"
}
}
}
}
}
}
}
}
}
},
"/fyi/settings/{typecode}": {
"post": {
"summary": "enable/disable certain subscription",
"tags": [
"FYI"
],
"parameters": [
{
"name": "typecode",
"in": "path",
"required": true,
"description": "fyi code",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
}
}
}
}
},
"required": true
},
"responses": {
"200": {
"description": "200 means successful",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/fyi/disclaimer/{typecode}": {
"get": {
"summary": "get disclaimer for a certain kind of fyi",
"tags": [
"FYI"
],
"parameters": [
{
"name": "typecode",
"in": "path",
"required": true,
"description": "fyi code, for example --M8, EA",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "receives the disclaimer message",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"DT": {
"type": "string",
"description": "disclaimer message"
},
"FC": {
"type": "string",
"description": "fyi code"
}
}
}
}
}
}
}
},
"put": {
"summary": "mark disclaimer read",
"tags": [
"FYI"
],
"parameters": [
{
"name": "typecode",
"in": "path",
"required": true,
"description": "fyi code, for example --M8, EA",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "200 means successful",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"T": {
"type": "integer"
},
"V": {
"type": "integer"
}
}
}
}
}
}
}
}
},
"/fyi/deliveryoptions": {
"get": {
"summary": "Get delivery options",
"tags": [
"FYI"
],
"description": "options for sending fyis to email and other devices\n",
"responses": {
"200": {
"description": "An object",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"M": {
"type": "integer",
"description": "Email option is enabled or not 0-off, 1-on."
},
"E": {
"type": "array",
"items": {
"type": "object",
"description": "device",
"properties": {
"NM": {
"type": "string",
"description": "device name"
},
"I": {
"type": "string",
"description": "device id"
},
"UI": {
"type": "string",
"description": "unique device id"
},
"A": {
"type": "string",
"description": "device is enabled or not 0-true, 1-false."
}
}
}
}
}
}
}
}
}
}
}
},
"/fyi/deliveryoptions/email": {
"put": {
"summary": "enable/disable email option",
"tags": [
"FYI"
],
"parameters": [
{
"name": "enabled",
"in": "query",
"required": true,
"description": "true/false",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "200 means successful",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"T": {
"type": "integer"
},
"V": {
"type": "integer"
}
}
}
}
}
}
}
}
},
"/fyi/deliveryoptions/device": {
"post": {
"summary": "enable/disable device option",
"tags": [
"FYI"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"devicename": {
"type": "string"
},
"deviceId": {
"type": "string"
},
"uiName": {
"type": "string"
},
"enabled": {
"type": "boolean"
}
}
}
}
},
"description": "device info",
"required": true
},
"responses": {
"200": {
"description": "200 means successful",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"T": {
"type": "integer"
},
"V": {
"type": "integer"
}
}
}
}
}
}
}
}
},
"/fyi/deliveryoptions/{deviceId}": {
"delete": {
"summary": "delete a device",
"tags": [
"FYI"
],
"parameters": [
{
"name": "deviceId",
"in": "path",
"required": true,
"description": "device ID",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "200 means successful",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"/fyi/notifications": {
"get": {
"summary": "Get a list of notifications",
"tags": [
"FYI"
],
"parameters": [
{
"name": "exclude",
"in": "query",
"description": "if set, don't set include",
"schema": {
"type": "string"
}
},
{
"name": "include",
"in": "query",
"description": "if set, don't set exclude",
"schema": {
"type": "string"
}
},
{
"name": "max",
"in": "query",
"required": true,
"description": "max number of fyis in response",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "An array",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/notifications"
}
}
}
}
}
}
},
"/fyi/notifications/more": {
"get": {
"summary": "Get more notifications based on a certain one",
"tags": [
"FYI"
],
"parameters": [
{
"name": "id",
"in": "query",
"required": true,
"description": "id of last notification in the list",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "An array",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/notifications"
}
}
}
}
}
}
},
"/fyi/notifications/{notificationId}": {
"put": {
"summary": "Get a list of notifications",
"tags": [
"FYI"
],
"parameters": [
{
"name": "notificationId",
"in": "path",
"required": true,
"description": "mark a notification read",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "when 200 receives, it means successful",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
}
},
"servers": [
{
"url": "https://localhost:5000/v1/portal"
}
],
"components": {
"requestBodies": {
"Body": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"acctIds": {
"type": "array",
"items": {
"type": "string",
"description": "account id"
}
}
}
}
}
},
"description": "an array of account ids",
"required": true
}
},
"schemas": {
"authStatus": {
"type": "object",
"properties": {
"authenticated": {
"description": "Brokerage session is authenticated",
"type": "boolean"
},
"connected": {
"description": "Connected to backend",
"type": "boolean"
},
"competing": {
"description": "Brokerage session is competing, e.g. user is logged in to IBKR Mobile, WebTrader, TWS or other trading platforms.",
"type": "boolean"
},
"fail": {
"description": "Authentication failed, why.",
"type": "string"
},
"message": {
"description": "System messages that may affect trading",
"type": "string"
},
"prompts": {
"type": "array",
"description": "Prompt messages that may affect trading or the account",
"items": {
"type": "string"
}
}
}
},
"contract": {
"description": "Contains all details of the contract, including rules you can use when placing orders",
"type": "object",
"properties": {
"r_t_h": {
"type": "boolean",
"description": "true means you can trade outside RTH(regular trading hours)"
},
"con_id": {
"type": "string",
"description": "same as that in request"
},
"company_name": {
"type": "string"
},
"exchange": {
"type": "string"
},
"local_symbol": {
"type": "string",
"description": "for exmple FB"
},
"instrument_type": {
"type": "string",
"description": "for example STK"
},
"currency": {
"type": "string"
},
"companyName": {
"type": "string"
},
"category": {
"type": "string"
},
"industry": {
"type": "string"
},
"rules": {
"type": "object",
"properties": {
"orderTypes": {
"type": "array",
"items": {
"type": "string",
"description": "store available order types for this contract"
}
},
"orderTypesOutside": {
"type": "array",
"items": {
"type": "string",
"description": "store available order types for this contract outside regular hours"
}
},
"defaultSize": {
"type": "number",
"description": "default quantity you can use to place an order"
},
"sizeIncrement": {
"type": "number"
},
"tifTypes": {
"type": "array",
"items": {
"type": "string",
"description": "store available time-in-force types"
}
},
"limitPrice": {
"type": "number",
"description": "default limit price you can use to prefill your order"
},
"stopprice": {
"type": "number",
"description": "default stop price you can use to prefill your order"
},
"preview": {
"type": "boolean",
"description": "if you can preview the order or not with the whatif end-point"
},
"displaySize": {
"type": "string"
},
"increment": {
"type": "string"
}
}
}
}
},
"history-data": {
"type": "object",
"properties": {
"start": {
"description": "start date time",
"type": "string"
},
"mdAvailability": {
"type": "string",
"description": "Market Data Availability. The field may contain two chars. The first char is the primary code: R = Realtime, D = Delayed,\nZ = Frozen, Y = Frozen Delayed. The second char is the secondary code: P = Snapshot Available, p = Consolidated.\n"
},
"barLength": {
"type": "integer"
},
"delay": {
"type": "integer"
},
"high": {
"type": "string",
"description": "price/volume/..."
},
"low": {
"type": "string",
"description": "price/volume/..."
},
"symbol": {
"type": "string"
},
"text": {
"type": "string"
},
"tickNum": {
"type": "string"
},
"timePeriod": {
"type": "string"
},
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"o": {
"type": "number",
"description": "open price"
},
"c": {
"type": "number",
"description": "close price"
},
"h": {
"type": "number",
"description": "high price"
},
"l": {
"type": "number",
"description": "low price"
},
"v": {
"type": "number",
"description": "volume"
},
"t": {
"type": "number",
"description": "unix time stamp"
}
}
}
},
"points": {
"type": "number",
"description": "total number of points"
},
"travelTime": {
"type": "number"
}
}
},
"trade": {
"type": "object",
"properties": {
"execution_id": {
"type": "string"
},
"symbol": {
"type": "string"
},
"side": {
"type": "string"
},
"order_description": {
"type": "string"
},
"trade_time": {
"type": "string"
},
"trade_time_r": {
"type": "number"
},
"size": {
"type": "string"
},
"price": {
"type": "string"
},
"submitter": {
"type": "string"
},
"exchange": {
"type": "string"
},
"comission": {
"type": "number"
},
"net_amount": {
"type": "number"
},
"account": {
"type": "string"
},
"company_name": {
"type": "string"
},
"contract_description_1": {
"type": "string"
},
"sec_type": {
"type": "string"
},
"conidex": {
"type": "string"
},
"position": {
"type": "string"
},
"clearing_id": {
"type": "string"
},
"clearing_name": {
"type": "string"
}
}
},
"modify-order": {
"type": "object",
"properties": {
"acctId": {
"type": "string"
},
"conid": {
"type": "integer"
},
"orderId": {
"type": "integer",
"description": "customer orderid"
},
"orderType": {
"type": "string",
"description": "for example LMT"
},
"outsideRTH": {
"type": "boolean"
},
"price": {
"type": "number"
},
"auxPrice": {
"type": "number"
},
"side": {
"type": "string",
"description": "SELL or BUY"
},
"listingExchange": {
"type": "string",
"description": "optional, not required"
},
"ticker": {
"type": "string"
},
"tif": {
"type": "string",
"description": "for example DAY"
},
"quantity": {
"type": "number",
"description": "usually integer, for some special cases can be float numbers"
}
}
},
"order-request": {
"type": "object",
"properties": {
"acctId": {
"description": "acctId is optional. It should be one of the accounts returned by\n/iserver/accounts. If not passed, the first one in the list is selected.\n",
"type": "string"
},
"conid": {
"description": "conid is the identifier of the security you want to trade, you can find the\nconid with /iserver/secdef/search.\n",
"type": "integer"
},
"secType": {
"type": "string",
"description": "conid:type for example 265598:STK"
},
"cOID": {
"description": "Customer Order ID. An arbitraty string that can be used to identify the order, e.g "my-fb-order". The\nvalue must be unique for a 24h span. Please do not set this value for child orders when placing a bracket order.\n",
"type": "string"
},
"parentId": {
"description": "When placing bracket orders, the child parentId must be equal to the cOId (customer order id) of the parent.\n",
"type": "string"
},
"orderType": {
"description": "orderType can be one of MKT (Market), LMT (Limit), STP (Stop) or STP_LIMIT (stop limit)\n",
"type": "string"
},
"listingExchange": {
"description": "listingExchange is optional. By default we use "SMART" routing. Possible values are available via this end\npoint: /v1/portal/iserver/contract/{{conid}}/info, see valid_exchange: e.g: SMART,AMEX,NYSE,\nCBOE,ISE,CHX,ARCA,ISLAND,DRCTEDGE,BEX,BATS,EDGEA,CSFBALGO,JE FFALGO,BYX,IEX,FOXRIVER,TPLUS1,NYSENAT,PSX\n",
"type": "string"
},
"outsideRTH": {
"description": "set to true if the order can be executed outside regular trading hours.\n",
"type": "boolean"
},
"price": {
"description": "optional if order is MKT, for LMT, this is the limit price. For STP this is the stop price.\n",
"type": "number"
},
"side": {
"type": "string",
"description": "SELL or BUY"
},
"ticker": {
"description": "",
"type": "string"
},
"tif": {
"description": "GTC (Good Till Cancel) or DAY. DAY orders are automatically cancelled at the end of the Day or Trading hours.\n",
"type": "string"
},
"referrer": {
"description": "for example QuickTrade",
"type": "string"
},
"quantity": {
"description": "usually integer, for some special cases can be float numbers",
"type": "number"
},
"useAdaptive": {
"description": "If true, the system will use the Adaptive Algo to submit the order\nhttps://www.interactivebrokers.com/en/index.php?f=19091\n",
"type": "boolean"
}
}
},
"order": {
"description": "contains all the order related info",
"type": "object",
"properties": {
"acct": {
"type": "string",
"description": "account id"
},
"conid": {
"type": "integer"
},
"orderDesc": {
"type": "string"
},
"description1": {
"type": "string"
},
"ticker": {
"type": "string",
"description": "for exmple FB"
},
"secType": {
"type": "string",
"description": "for example STK"
},
"listingExchange": {
"type": "string",
"description": "for example NASDAQ.NMS"
},
"remainingQuantity": {
"type": "string"
},
"filledQuantity": {
"type": "string"
},
"companyName": {
"type": "string"
},
"status": {
"type": "string",
"description": "PendingSubmit - Indicates the order was sent, but confirmation has not been received that it has been received by the destination. \n Occurs most commonly if an exchange is closed.\nPendingCancel - Indicates that a request has been sent to cancel an order but confirmation has not been received of its cancellation. PreSubmitted - Indicates that a simulated order type has been accepted by the IBKR system and that this order has yet to be elected. \n The order is held in the IBKR system until the election criteria are met. At that time the order is transmitted to the order destination as specified. \nSubmitted - Indicates that the order has been accepted at the order destination and is working. Cancelled - Indicates that the balance of the order has been confirmed cancelled by the IB system. \n This could occur unexpectedly when IB or the destination has rejected the order. \nFilled - Indicates that the order has been completely filled. Inactive - Indicates the order is not working, for instance if the order was invalid and triggered an error message,\n or if the order was to short a security and shares have not yet been located. \n"
},
"origOrderType": {
"type": "string",
"description": "for example Limit"
},
"side": {
"type": "string",
"description": "BUY or SELL"
},
"price": {
"type": "number"
},
"bgColor": {
"type": "string",
"description": "back-ground color"
},
"fgColor": {
"type": "string"
},
"orderId": {
"type": "integer"
},
"parentId": {
"description": "Only exists in child order of bracket",
"type": "integer"
}
}
},
"scanner-params": {
"type": "object",
"properties": {
"instrument": {
"type": "string",
"description": "for example-STK"
},
"type": {
"type": "string",
"description": "for example-TOP_PERC_GAIN"
},
"filter": {
"type": "array",
"items": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"value": {
"type": "number"
}
}
}
},
"location": {
"type": "string"
},
"size": {
"type": "string"
}
}
},
"set-account": {
"type": "object",
"properties": {
"acctId": {
"type": "string",
"description": "Account ID"
}
}
},
"position": {
"type": "array",
"items": {
"type": "object",
"description": "Account Information",
"properties": {
"acctId": {
"type": "string"
},
"conid": {
"type": "integer"
},
"contractDesc": {
"type": "string"
},
"assetClass": {
"type": "string"
},
"position": {
"type": "number"
},
"mktPrice": {
"type": "number"
},
"mktValue": {
"type": "number"
},
"currency": {
"type": "string"
},
"avgCost": {
"type": "number"
},
"avgPrice": {
"type": "number"
},
"realizedPnl": {
"type": "number"
},
"unrealizedPnl": {
"type": "number"
},
"exchs": {
"type": "string"
},
"expiry": {
"type": "string"
},
"putOrCall": {
"type": "string"
},
"multiplier": {
"type": "number"
},
"strike": {
"type": "number"
},
"exerciseStyle": {
"type": "string"
},
"undConid": {
"type": "integer"
},
"conExchMap": {
"type": "array",
"items": {
"type": "string"
}
},
"baseMktValue": {
"type": "number"
},
"baseMktPrice": {
"type": "number"
},
"baseAvgCost": {
"type": "number"
},
"baseAvgPrice": {
"type": "number"
},
"baseRealizedPnl": {
"type": "number"
},
"baseUnrealizedPnl": {
"type": "number"
},
"name": {
"type": "string"
},
"lastTradingDay": {
"type": "string"
},
"group": {
"type": "string"
},
"sector": {
"type": "string"
},
"sectorGroup": {
"type": "string"
},
"ticker": {
"type": "string"
},
"undComp": {
"type": "string"
},
"undSym": {
"type": "string"
},
"fullName": {
"type": "string"
},
"pageSize": {
"type": "integer"
},
"model": {
"type": "string"
}
}
}
},
"allocation": {
"type": "array",
"items": {
"type": "object",
"description": "allocation",
"properties": {
"assetClass": {
"type": "object",
"description": "portfolio allocation by asset class",
"properties": {
"long": {
"type": "object",
"description": "long positions allocation",
"properties": {
"STK": {
"type": "number"
},
"OPT": {
"type": "number"
},
"FUT": {
"type": "number"
},
"WAR": {
"type": "number"
},
"BOND": {
"type": "number"
},
"CASH": {
"type": "number"
}
}
},
"short": {
"type": "object",
"description": "short positions allocation",
"properties": {
"STK": {
"type": "number"
},
"OPT": {
"type": "number"
},
"FUT": {
"type": "number"
},
"WAR": {
"type": "number"
},
"BOND": {
"type": "number"
},
"CASH": {
"type": "number"
}
}
}
}
},
"sector": {
"type": "object",
"description": "portfolio allocation by sector",
"properties": {
"long": {
"type": "object",
"description": "long positions allocation",
"properties": {
"Others": {
"type": "number"
},
"Utilities": {
"type": "number"
},
"Energy": {
"type": "number"
},
"Technology": {
"type": "number"
},
"Financial": {
"type": "number"
},
"Communications": {
"type": "number"
}
}
},
"short": {
"type": "object",
"description": "short positions allocation",
"properties": {
"Industrial": {
"type": "number"
},
"Consumer": {
"type": "number"
},
"Diversified": {
"type": "number"
}
}
}
}
},
"group": {
"type": "object",
"description": "portfolio allocation by group",
"properties": {
"long": {
"type": "object",
"description": "long positions allocation",
"properties": {
"Computers": {
"type": "number"
},
"Semiconductors": {
"type": "number"
},
"Others": {
"type": "number"
},
"Chemicals": {
"type": "number"
},
"Apparel": {
"type": "number"
},
"Communications": {
"type": "number"
}
}
},
"short": {
"type": "object",
"description": "short positions allocation",
"properties": {
"Banks": {
"type": "number"
},
"Airlines": {
"type": "number"
},
"Internet": {
"type": "number"
}
}
}
}
}
}
}
},
"accounts": {
"type": "array",
"items": {
"$ref": "#/components/schemas/account"
}
},
"account": {
"type": "object",
"description": "account information",
"properties": {
"id": {
"type": "string"
},
"accountId": {
"type": "string"
},
"accountVan": {
"type": "string"
},
"accountTitle": {
"type": "string"
},
"displayName": {
"type": "string"
},
"accountAlias": {
"type": "string"
},
"accountStatus": {
"type": "number"
},
"currency": {
"type": "string"
},
"type": {
"type": "string"
},
"tradingType": {
"type": "string"
},
"faclient": {
"type": "boolean"
},
"parent": {
"type": "string"
},
"desc": {
"type": "string"
},
"covestor": {
"type": "boolean"
},
"master": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"officialTitle": {
"type": "string"
}
}
}
}
},
"summary": {
"type": "object",
"description": "account information",
"properties": {
"total": {
"type": "object",
"properties": {
"chg": {
"type": "string",
"description": "total change amount"
},
"rtn": {
"type": "string",
"description": "change percent"
},
"incompleteData": {
"type": "boolean",
"description": "set to true if any external account data is not available for starting or ending date, resulting in potentially unusual total values."
},
"endVal": {
"type": "string"
},
"startVal": {
"type": "string"
}
}
},
"startDate": {
"type": "string",
"description": "date format-- yyyy-MM-dd"
},
"excludedAccounts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"lastUpdateAttempt": {
"type": "string"
},
"fiName": {
"type": "string"
},
"acctTitle": {
"type": "string"
},
"acctNumAtFI": {
"type": "string"
},
"acctId": {
"type": "string"
},
"lastUpdate": {
"type": "string"
},
"harvestCode": {
"type": "integer"
},
"lastUpdateStatusCode": {
"type": "string"
},
"rc": {
"type": "integer"
}
}
}
},
"lastSuccessfulUpdate": {
"type": "string"
},
"accountSummaries": {
"type": "array",
"items": {
"type": "object",
"properties": {
"chg": {
"type": "string"
},
"hasAccounts": {
"type": "string"
},
"accountTypeName": {
"type": "string"
},
"rtn": {
"type": "string"
},
"endVal": {
"type": "string"
},
"accountTypeCode": {
"type": "string"
},
"startVal": {
"type": "string"
}
}
}
},
"endDate": {
"type": "string"
},
"hasExternalAccounts": {
"type": "boolean",
"description": "indicator of user having configured any external accounts"
},
"rc": {
"type": "integer"
},
"currency": {
"type": "string"
},
"userId": {
"type": "string"
},
"pm": {
"type": "string"
},
"view": {
"type": "string"
},
"balanceByDate": {
"type": "object",
"properties": {
"series": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"groupId": {
"type": "string"
},
"name": {
"type": "string"
},
"date": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "number"
}
}
}
}
}
}
}
}
}
},
"ledger": {
"type": "object",
"properties": {
"commoditymarketvalue": {
"type": "number"
},
"futuremarketvalue": {
"type": "number"
},
"settledcash": {
"type": "number"
},
"exchangerate": {
"type": "number"
},
"sessionid": {
"type": "integer"
},
"cashbalance": {
"type": "number"
},
"corporatebondsmarketvalue": {
"type": "number"
},
"warrantsmarketvalue": {
"type": "number"
},
"netliquidationvalue": {
"type": "number"
},
"interest": {
"type": "number"
},
"unrealizedpnl": {
"type": "number"
},
"stockmarketvalue": {
"type": "number"
},
"moneyfunds": {
"type": "number"
},
"currency": {
"type": "string"
},
"realizedpnl": {
"type": "number"
},
"funds": {
"type": "number"
},
"acctcode": {
"type": "string"
},
"issueroptionsmarketvalue": {
"type": "number"
},
"key": {
"type": "string"
},
"timestamp": {
"type": "integer"
},
"severity": {
"type": "integer"
}
}
},
"calendar_request": {
"type": "object",
"properties": {
"date": {
"type": "object",
"properties": {
"start": {
"type": "string",
"description": "start date of a period. for example 20180808-0400"
},
"end": {
"type": "string",
"description": "end date of a period. for example 20180808-0400"
}
}
},
"filters": {
"type": "object",
"properties": {
"recently_held": {
"type": "string",
"description": "value can be 'true' or 'false'."
},
"corporate_earnings": {
"type": "string",
"description": "value can be 'true' or 'false'."
},
"DivExDates": {
"type": "string",
"description": "value can be 'true' or 'false'."
},
"ipo": {
"type": "string",
"description": "value can be 'true' or 'false'."
},
"splits": {
"type": "string",
"description": "value can be 'true' or 'false'."
},
"corporate_events": {
"type": "string",
"description": "value can be 'true' or 'false'."
},
"economic_events": {
"type": "string",
"description": "value can be 'true' or 'false'."
},
"option_show_monthly": {
"type": "string",
"description": "value can be 'true' or 'false'."
},
"option_show_weekly": {
"type": "string",
"description": "value can be 'true' or 'false'."
},
"country": {
"type": "string",
"description": "default is 'All'."
},
"limit": {
"type": "string",
"description": "default is '250'."
},
"limit_region": {
"type": "string",
"description": "default is '50'."
}
}
}
}
},
"events": {
"type": "array",
"description": "events",
"items": {
"type": "object",
"properties": {
"index_date_type": {
"type": "string"
},
"event_type": {
"type": "string"
},
"data": {
"type": "object",
"description": "will be different for different event types"
},
"conids": {
"type": "array",
"items": {
"type": "string",
"description": "conid in string"
}
},
"index_date": {
"type": "string",
"description": "for exmple 20180817T040000+0000"
},
"source": {
"type": "string",
"description": "for example RSE"
},
"event_key": {
"type": "string",
"description": "for example 11662135"
},
"tooltips": {
"type": "object"
},
"status": {
"type": "string"
}
}
}
},
"performance": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"cps": {
"type": "object",
"description": "Cumulative performance data",
"properties": {
"dates": {
"type": "array",
"description": "array of dates, the length should be same as the length of returns inside data.",
"items": {
"type": "string",
"description": "format-- yyyyMMdd"
}
},
"freq": {
"type": "string",
"description": "D means Day"
},
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"idType": {
"type": "string",
"description": "for example-- acctid"
},
"start": {
"type": "string",
"description": "start date-- yyyyMMdd"
},
"baseCurrency": {
"type": "string"
},
"returns": {
"type": "array",
"description": "each value stands for price change percent of corresponding date in dates array",
"items": {
"type": "number"
}
},
"end": {
"type": "string",
"description": "end date-- yyyyMMdd"
}
}
}
}
}
},
"tpps": {
"type": "object",
"description": "Time period performance data",
"properties": {
"dates": {
"type": "array",
"description": "array of dates, the length should be same as the length of returns inside data.",
"items": {
"type": "string",
"description": "format-- yyyyMMdd"
}
},
"freq": {
"type": "string",
"description": "M means Month"
},
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"idType": {
"type": "string",
"description": "for example-- acctid"
},
"start": {
"type": "string",
"description": "start date-- yyyyMMdd"
},
"baseCurrency": {
"type": "string"
},
"returns": {
"type": "array",
"description": "each value stands for price change percent of corresponding date in dates array",
"items": {
"type": "number"
}
},
"end": {
"type": "string",
"description": "end date-- yyyyMMdd"
}
}
}
}
}
},
"nav": {
"type": "object",
"description": "Net asset value data for the account or consolidated accounts. NAV data is not applicable to benchmarks.",
"properties": {
"dates": {
"type": "array",
"description": "array of dates, the length should be same as the length of returns inside data.",
"items": {
"type": "string",
"description": "format--yyyyMMdd"
}
},
"freq": {
"type": "string",
"description": "D means Day"
},
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"idType": {
"type": "string",
"description": "for example-- acctid"
},
"start": {
"type": "string",
"description": "start date-- yyyyMMdd"
},
"baseCurrency": {
"type": "string"
},
"returns": {
"type": "array",
"description": "each value stands for price change percent of corresponding date in dates array",
"items": {
"type": "number"
}
},
"end": {
"type": "string",
"description": "end date-- yyyyMMdd"
}
}
}
}
}
},
"pm": {
"type": "string"
},
"included": {
"type": "array",
"items": {
"type": "string",
"description": "account id"
}
},
"currencyType": {
"type": "string"
},
"rc": {
"type": "integer"
}
}
},
"secdef": {
"type": "array",
"items": {
"type": "object",
"description": "security definition information",
"properties": {
"conid": {
"type": "integer"
},
"name": {
"type": "string"
},
"assetClass": {
"type": "string"
},
"expiry": {
"type": "string"
},
"lastTradingDay": {
"type": "string"
},
"group": {
"type": "string"
},
"putOrCall": {
"type": "string"
},
"sector": {
"type": "string"
},
"sectorGroup": {
"type": "string"
},
"strike": {
"type": "number"
},
"ticker": {
"type": "string"
},
"undConid": {
"type": "integer"
},
"fullName": {
"type": "string"
},
"pageSize": {
"type": "integer"
}
}
}
},
"futures": {
"type": "array",
"items": {
"type": "object",
"description": "future contract information",
"properties": {
"symbol": {
"type": "string"
},
"conid": {
"type": "integer",
"description": "conid of the future contract"
},
"underlyingConid": {
"type": "integer"
},
"expirationDate": {
"type": "string"
},
"ltd": {
"type": "string",
"description": "last trading day"
}
}
}
},
"notifications": {
"type": "array",
"items": {
"type": "object",
"description": "notification",
"properties": {
"D": {
"type": "string",
"description": "notification date"
},
"ID": {
"type": "string",
"description": "unique way to reference this notification"
},
"FC": {
"type": "string",
"description": "FYI code, we can use it to find whether the disclaimer is accepted or not in settings"
},
"MD": {
"type": "string",
"description": "content of notification"
},
"MS": {
"type": "string",
"description": "title of notification"
},
"R": {
"type": "string",
"description": "0-unread, 1-read"
}
}
}
}
}
}
}
'''

Warning at `blackify` step

Hi, I'm getting these warnings with an installable renderer:

[13:18:31] WARNING  Black failed to post-process file with an error: Cannot parse: 3:4: The client is provided with async and sync adapters.. Currently  blackify.py:20
                    it happens on non python files, you can safely ignore this message.                                                                                
           WARNING  Black failed to post-process file with an error: Cannot parse: 2:8: include README.rst CHANGES LICENSE. Currently it happens on non  blackify.py:20
                    python files, you can safely ignore this message.         

I think it's relatively easy to recursively filter non *.py files in the folder before feeding the stream to black, but I haven't looked at the post-processor API yet. Not critical though, just FYI to keep track of the things that could be improved.

Please update version of schemathesis

Hello,

I have a dependency no swagger-codegen in some code I inherited from a colleague. In my test suites I make frequent use of Hypothesis.
Currently I cannot update to hypothesis = 6.14.5 because swagger-codegen depends on schemathesis = 1.1.0 as production dependency and schemathesis v.1.1.0 requires hypothesis >=4.32, < 6.0.

Looking at the GitHub of SchemaThesis, they arrived at 3.9.7.

I would be very glad if the version could be bumbed. Thank you very much.

generating classes for no direct endpoint

Hi,
I have a openapi v3 file for which i'm wanting to generate python client classes

I have two broad issues with the generated code at present.

where a schema is used as the root of an endpoints request or response, things seem ok
but if a schema only plays a part a higher level schema, then the class name generated is None

eg below, contract corresponds to an endpoint, but rules only exists within contract, it has no endpoint of its own.

"schemas": { "authStatus": { "type": "object", "properties": { "authenticated": { "description": "Brokerage session is authenticated", "type": "boolean" }, "connected": { "description": "Connected to backend", "type": "boolean" }, "competing": { "description": "Brokerage session is competing, e.g. user is logged in to IBKR Mobile, WebTrader, TWS or other trading platforms.", "type": "boolean" }, "fail": { "description": "Authentication failed, why.", "type": "string" }, "message": { "description": "System messages that may affect trading", "type": "string" }, "prompts": { "type": "array", "description": "Prompt messages that may affect trading or the account", "items": { "type": "string" } } } }, "contract": { "description": "Contains all details of the contract, including rules you can use when placing orders", "type": "object", "properties": { "r_t_h": { "type": "boolean", "description": "true means you can trade outside RTH(regular trading hours)" }, "con_id": { "type": "string", "description": "same as that in request" }, "company_name": { "type": "string" }, "exchange": { "type": "string" }, "local_symbol": { "type": "string", "description": "for exmple FB" }, "instrument_type": { "type": "string", "description": "for example STK" }, "currency": { "type": "string" }, "companyName": { "type": "string" }, "category": { "type": "string" }, "industry": { "type": "string" }, "rules": { "type": "object", "properties": { "orderTypes": { "type": "array", "items": { ........

Not found http://petstore.swagger.io:8080/api/v3/openapi.json

Hi swagger api team,

READ ME tells to run "swagger_codegen generate http://petstore.swagger.io:8080/api/v3/openapi.json petstore", but this openapi.json file is not existed.

When I change to use "swagger_codegen generate https://petstore.swagger.io/v2/swagger.json petstore" to start a stub server, exception is as below:

Generating from swagger.json to . (petstore)
Traceback (most recent call last):
File "/home/emc/vivian/swagger_codegen-master/env/bin/swagger_codegen", line 8, in
sys.exit(app())
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/typer/main.py", line 211, in call
return get_command(self)()
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/typer/main.py", line 494, in wrapper
return callback(**use_params) # type: ignore
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/swagger_codegen/cli/main.py", line 37, in generate
base_schema = load_base_schema(uri)
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/swagger_codegen/parsing/loaders.py", line 43, in load_base_schema
add_x_names(schema)
File "/home/emc/vivian/swagger_codegen-master/env/lib/python3.8/site-packages/swagger_codegen/parsing/loaders.py", line 48, in add_x_names
for name, schema in schema["components"]["schemas"].items():
KeyError: 'components'

no cli __main__.py

Hi,

I'm following the doc instructions, but running into trouble
I've installed the package with pip
running the suggested command line to generate code complained about no main
python -m swagger_codegen generate https://petstore3.swagger.io/api/v3/openapi.json petstore
C:...\Python\Python37\python.exe: No module named swagger_codegen.main; 'swagger_codegen' is a package and cannot be directly executed

so i renamed cli\main.py to cli_main_.py and run this command instead (note swagger_codegen.cli instead of swagger_codegen)
python -m swagger_codegen.cli generate https://petstore3.swagger.io/api/v3/openapi.json petstore
Generating from https://petstore3.swagger.io/api/v3/openapi.json to . (petstore)

This appears to run successfully
Loaded schema OpenApi30 for Swagger Petstore - OpenAPI 3.0 (1.0.5) with 19 endpoint(s)

Boolean in additionalProperties results in a stacktrace

When trying to generate a client for a json file containing "additionalProperties": false the generation will fail with the below stacktrace. If replacing all occurances of "additionalProperties": false with "additionalProperties": {} it works. According to https://swagger.io/docs/specification/data-models/keywords/ it's valid to use booleans.

$ swagger_codegen generate swagger.json someproject
Generating from swagger.json to . (someproject)
Loaded schema OpenApi30 for External Job API (v1) with 3 endpoint(s)
Traceback (most recent call last):
  File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python39\Scripts\swagger_codegen.exe\__main__.py", line 7, in <module>
  File "c:\python39\lib\site-packages\typer\main.py", line 211, in __call__
    return get_command(self)()
  File "c:\python39\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\python39\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\python39\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python39\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python39\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\python39\lib\site-packages\typer\main.py", line 494, in wrapper
    return callback(**use_params)  # type: ignore
  File "c:\python39\lib\site-packages\swagger_codegen\cli\main.py", line 45, in generate
    renderer.render(list(endpoints))
  File "c:\python39\lib\site-packages\swagger_codegen\render\renderers\package.py", line 66, in render
    self._render_api(api)
  File "c:\python39\lib\site-packages\swagger_codegen\render\renderers\package.py", line 120, in _render_api
    self._render_endpoint(api_dir, endpoint)
  File "c:\python39\lib\site-packages\swagger_codegen\render\renderers\package.py", line 130, in _render_endpoint
    if endpoint.body_request:
  File "c:\python39\lib\site-packages\swagger_codegen\parsing\endpoint.py", line 45, in body_request
    data_type=make_data_type(self.endpoint.body),
  File "c:\python39\lib\site-packages\swagger_codegen\parsing\data_type_parser.py", line 75, in make_data_type
    inner_type = make_data_type(
  File "c:\python39\lib\site-packages\swagger_codegen\parsing\data_type_parser.py", line 22, in make_data_type
    if field in schema:
TypeError: argument of type 'bool' is not iterable

minor improvements

some tags may contain spaces
it would be useful to automatically handle this in the generated code
it would also be useful to print out where the main output is - it's not obvious in a project that already contains many files

Cannot run tests

I tried to run the test suite. I need to run it in an Conda environment because Debian Testing does not provide Python 3.8.

poetry install
poetry run pytest

The (relevant) output I got is:

============================= test session starts ==============================
platform linux -- Python 3.8.0, pytest-6.2.1, py-1.10.0, pluggy-0.13.1
rootdir: /path/to/swagger_codegen
plugins: aiohttp-0.3.0, lazy-fixture-0.6.3, subtests-0.2.1, schemathesis-1.1.0, hypothesis-5.47.0, cov-2.10.1
collected 23 items / 5 errors / 18 selected

==================================== ERRORS ====================================
__________ ERROR collecting src/swagger_codegen/render/test_utils.py ___________
ImportError while importing test module '/path/to/swagger_codegen/src/swagger_codegen/render/test_utils.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.miniconda3/envs/fresh/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named 'swagger_codegen.render.test_utils'
_____________________ ERROR collecting tests/test_json.py ______________________
ImportError while importing test module '/path/to/swagger_codegen/tests/test_json.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.miniconda3/envs/fresh/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_json.py:6: in <module>
    from swagger_codegen.api import json
E   ImportError: cannot import name 'json' from 'swagger_codegen.api' ($HOME/.miniconda3/envs/fresh/lib/python3.8/site-packages/swagger_codegen/api/__init__.py)
____________________ ERROR collecting tests/test_loaders.py ____________________
ImportError while importing test module '/path/to/swagger_codegen/tests/test_loaders.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.miniconda3/envs/fresh/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_loaders.py:3: in <module>
    from swagger_codegen.parsing.loaders import from_file, load_base_schema, tuple_startswith
E   ImportError: cannot import name 'tuple_startswith' from 'swagger_codegen.parsing.loaders' ($HOME/.miniconda3/envs/fresh/lib/python3.8/site-packages/swagger_codegen/parsing/loaders.py)
_______________ ERROR collecting tests/test_params_converter.py ________________
ImportError while importing test module '/path/to/swagger_codegen/tests/test_params_converter.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.miniconda3/envs/fresh/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_params_converter.py:6: in <module>
    from swagger_codegen.api.adapter.params_converter import (
E   ModuleNotFoundError: No module named 'swagger_codegen.api.adapter.params_converter'
_____________ ERROR collecting tests/integration/test_adapters.py ______________
ImportError while importing test module '/path/to/swagger_codegen/tests/integration/test_adapters.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.miniconda3/envs/fresh/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/integration/test_adapters.py:8: in <module>
    import httpx
E   ModuleNotFoundError: No module named 'httpx'
=========================== short test summary info ============================
ERROR src/swagger_codegen/render/test_utils.py
ERROR tests/test_json.py
ERROR tests/test_loaders.py
ERROR tests/test_params_converter.py
ERROR tests/integration/test_adapters.py
!!!!!!!!!!!!!!!!!!! Interrupted: 5 errors during collection !!!!!!!!!!!!!!!!!!!!
============================== 5 errors in 0.40s ===============================

This is quite unfortunate because it means I am unable to test my changes. Maybe a short explanation how to run the tests could be given?

KeyError on expected headers

Hi!

I have a test case of a server-side validation error where the server responds with the most minimal set of headers, like:

{'Transfer-Encoding': 'chunked', 'Date': 'Mon, 24 Aug 2020 13:21:06 GMT', 'Server': 'Warp/3.3.13'}

The body of a validation error message may be just a bytestring of:

b'Error in $.userId: invalid UUID'

Here's how the currently autogenerated client fails with these responses:

test_service.py::test_service FAILED                                     [100%]
tests/myapp_with_client/test_service.py:5 (test_service)
tests/myapp_with_client/test_service.py:14: in test_service
    problem=Problem("{}"),
src/my_service/myapp_with_client/service.py:83: in map
    userId=user_id,
.venv/lib/python3.8/site-packages/autogenerated_client/apis/api/post__link_problem.py:57: in make_request
    }, m)
.venv/lib/python3.8/site-packages/autogenerated_client/lib/base.py:41: in make_request
    result = self._client.call_api(api_request)
.venv/lib/python3.8/site-packages/autogenerated_client/lib/client.py:21: in call_api
    return self._adapter.call(method)
.venv/lib/python3.8/site-packages/autogenerated_client/lib/adapter/requests.py:35: in call
    return methods[api_request.method](api_request=api_request)
.venv/lib/python3.8/site-packages/autogenerated_client/lib/adapter/requests.py:60: in _write
    return self._response(make_request(**params))
.venv/lib/python3.8/site-packages/autogenerated_client/lib/adapter/requests.py:73: in _response
    content_type=response.headers["Content-Type"],
.venv/lib/python3.8/site-packages/requests/structures.py:54: in __getitem__
    return self._store[key.lower()][1]
E   KeyError: 'content-type'

While it's a reasonable solution in a dynamic language, I think it would be beneficial to not to hide the actual bytestring body of the error response, or probably handle missing headers more gracefully. I acknowledge there's not much reason for the JSON api to do so, as it won't be able to recover from a text response anyways, but I think it can help to reveal the content of the response body in a traceback. The content-type header in this particular case could be explicitly set to text/plain, as it's the protocol default (at least, according to https://www.w3.org/Protocols/rfc1341/4_Content-Type.html).

KeyError on a valid minimal schema that doesn't define "components"

Hi @asyncee

I've got a minimal spec that passes OAS3 validation, yet the codegen fails around schema components. I think it expects shared schemas to exist, and I wonder if there's a quick solution to specs without defined schemas.

Traceback (most recent call last):
  File "/Users/coderfromhere/project/.venv/bin/swagger_codegen", line 8, in <module>
    sys.exit(app())
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/typer/main.py", line 211, in __call__
    return get_command(self)()
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/typer/main.py", line 494, in wrapper
    return callback(**use_params)  # type: ignore
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/swagger_codegen/cli/main.py", line 37, in generate
    base_schema = load_base_schema(uri)
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/swagger_codegen/parsing/loaders.py", line 43, in load_base_schema
    add_x_names(schema)
  File "/Users/coderfromhere/project/.venv/lib/python3.8/site-packages/swagger_codegen/parsing/loaders.py", line 55, in add_x_names
    for name, schema in schema["components"]["schemas"].items():
KeyError: 'components'

The spec:

{
  "openapi": "3.0.0",
  "info": {
    "title": "Title",
    "description": "Desc",
    "contact": {
      "name": "Me",
      "url": "https://github.com/coderfromhere",
      "email": "[email protected]"
    },
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api-dev.example.com/v2",
      "description": "Development server"
    },
    {
      "url": "https://api-integration.example.com/v2",
      "description": "Integration server"
    },
    {
      "url": "https://api.example.com/v2",
      "description": "Production server"
    }
  ],
  "paths": {
    "/auth": {
      "post": {
        "tags": [
          "Authentication & Authorization"
        ],
        "summary": "Authentication",
        "description": "Authentication",
        "operationId": "auth",
        "parameters": [
          {
            "name": "Accept-Language",
            "in": "header",
            "description": "List of acceptable human languages for response.",
            "required": false,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-HTTP-Method-Override",
            "in": "header",
            "description": "Put here the HTTP method you want, when making call by the POST method to avoid interference of nasty firewall rules.",
            "required": false,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "apiKey": {
                    "type": "string",
                    "description": "The open api key that is given to the specific system."
                  },
                  "locale": {
                    "type": "string",
                    "description": "Locale"
                  },
                  "timezone": {
                    "type": "string",
                    "description": "Timezone in POSIX format."
                  },
                  "source": {
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "tenant": {
                            "type": "string",
                            "description": "The tenant to which the origin belongs."
                          }
                        }
                      },
                      {
                        "title": "Source",
                        "required": [
                          "type",
                          "name",
                          "version",
                          "instance"
                        ],
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "enum": [
                              "system",
                              "database",
                              "file-system"
                            ],
                            "description": "The type of the source."
                          },
                          "name": {
                            "type": "string",
                            "description": "The name of the source."
                          },
                          "version": {
                            "type": "string",
                            "description": "The version of the source."
                          },
                          "instance": {
                            "type": "string",
                            "description": "Specific instance of the source."
                          },
                        },
                        "x-tags": [
                          "domain"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "title": "Response",
                      "required": [
                        "code",
                        "locale",
                      ],
                      "type": "object",
                      "properties": {
                        "code": {
                          "minimum": 0,
                          "type": "integer",
                          "description": "Response code"
                        },
                        "locale": {
                          "type": "string",
                          "description": "Response locale"
                        }
                      },
                      "x-tags": [
                        "system"
                      ]
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}

further class None examples

Please see the enclosed json
'''
{
"openapi": "3.0.0",
"info": {
"title": "Client Portal Web API",
"description": "Production version of the Client Portal Web API",
"version": "1.0.0"
},
"paths": {
"/trsrv/futures": {
"get": {
"summary": "Security Futures by Symbol",
"description": "Returns a list of non-expired future contracts for given symbol(s)",
"tags": [
"Contract"
],
"parameters": [
{
"in": "query",
"name": "symbols",
"description": "list of case-sensitive symbols separated by comma",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "returns an object with symbol and and array of its future contracts",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"symbol": {
"$ref": "#/components/schemas/futures"
}
}
}
}
}
},
"500": {
"description": "error while processing the request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/portfolio/{accountId}/summary": {
"get": {
"summary": "Account Summary",
"description": "Returns information about margin, cash balances and other information related to specified account. See also /portfolio/{accountId}/ledger. /portfolio/accounts or /portfolio/subaccounts must be called prior to this endpoint.",
"tags": [
"Account",
"Portfolio"
],
"parameters": [
{
"name": "accountId",
"in": "path",
"required": true,
"description": "account id",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "returns an object containing account summary. The object contains multiple properties. A property is sufficed with -c if its provides commodity value, -s if it provides security value and -c if its UKL segment value",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"accountready": {
"$ref": "#/components/schemas/summary"
},
"accounttype": {
"$ref": "#/components/schemas/summary"
},
"accruedcash": {
"$ref": "#/components/schemas/summary"
},
"accruedcash-c": {
"$ref": "#/components/schemas/summary"
},
"accruedcash-f": {
"$ref": "#/components/schemas/summary"
},
"accruedcash-s": {
"$ref": "#/components/schemas/summary"
},
"accrueddividend": {
"$ref": "#/components/schemas/summary"
},
"accrueddividend-c": {
"$ref": "#/components/schemas/summary"
},
"accrueddividend-f": {
"$ref": "#/components/schemas/summary"
},
"accrueddividend-s": {
"$ref": "#/components/schemas/summary"
},
"availablefunds": {
"$ref": "#/components/schemas/summary"
},
"availablefunds-c": {
"$ref": "#/components/schemas/summary"
},
"availablefunds-f": {
"$ref": "#/components/schemas/summary"
},
"availablefunds-s": {
"$ref": "#/components/schemas/summary"
},
"billable": {
"$ref": "#/components/schemas/summary"
},
"billable-c": {
"$ref": "#/components/schemas/summary"
},
"billable-f": {
"$ref": "#/components/schemas/summary"
},
"billable-s": {
"$ref": "#/components/schemas/summary"
},
"buyingpower": {
"$ref": "#/components/schemas/summary"
},
"cushion": {
"$ref": "#/components/schemas/summary"
},
"daytradesremaining": {
"$ref": "#/components/schemas/summary"
},
"daytradesremainingt+1": {
"$ref": "#/components/schemas/summary"
},
"daytradesremainingt+2": {
"$ref": "#/components/schemas/summary"
},
"daytradesremainingt+3": {
"$ref": "#/components/schemas/summary"
},
"daytradesremainingt+4": {
"$ref": "#/components/schemas/summary"
},
"equitywithloanvalue": {
"$ref": "#/components/schemas/summary"
},
"equitywithloanvalue-c": {
"$ref": "#/components/schemas/summary"
},
"equitywithloanvalue-f": {
"$ref": "#/components/schemas/summary"
},
"equitywithloanvalue-s": {
"$ref": "#/components/schemas/summary"
},
"excessliquidity": {
"$ref": "#/components/schemas/summary"
},
"excessliquidity-c": {
"$ref": "#/components/schemas/summary"
},
"excessliquidity-f": {
"$ref": "#/components/schemas/summary"
},
"excessliquidity-s": {
"$ref": "#/components/schemas/summary"
},
"fullavailablefunds": {
"$ref": "#/components/schemas/summary"
},
"fullavailablefunds-c": {
"$ref": "#/components/schemas/summary"
},
"fullavailablefunds-f": {
"$ref": "#/components/schemas/summary"
},
"fullavailablefunds-s": {
"$ref": "#/components/schemas/summary"
},
"fullexcessliquidity": {
"$ref": "#/components/schemas/summary"
},
"fullexcessliquidity-c": {
"$ref": "#/components/schemas/summary"
},
"fullexcessliquidity-f": {
"$ref": "#/components/schemas/summary"
},
"fullexcessliquidity-s": {
"$ref": "#/components/schemas/summary"
},
"fullinitmarginreq": {
"$ref": "#/components/schemas/summary"
},
"fullinitmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"fullinitmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"fullinitmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"fullmaintmarginreq": {
"$ref": "#/components/schemas/summary"
},
"fullmaintmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"fullmaintmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"fullmaintmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"grosspositionvalue": {
"$ref": "#/components/schemas/summary"
},
"grosspositionvalue-c": {
"$ref": "#/components/schemas/summary"
},
"grosspositionvalue-f": {
"$ref": "#/components/schemas/summary"
},
"grosspositionvalue-s": {
"$ref": "#/components/schemas/summary"
},
"guarantee": {
"$ref": "#/components/schemas/summary"
},
"guarantee-c": {
"$ref": "#/components/schemas/summary"
},
"guarantee-f": {
"$ref": "#/components/schemas/summary"
},
"guarantee-s": {
"$ref": "#/components/schemas/summary"
},
"highestseverity": {
"$ref": "#/components/schemas/summary"
},
"highestseverity-c": {
"$ref": "#/components/schemas/summary"
},
"highestseverity-f": {
"$ref": "#/components/schemas/summary"
},
"highestseverity-s": {
"$ref": "#/components/schemas/summary"
},
"indianstockhaircut": {
"$ref": "#/components/schemas/summary"
},
"indianstockhaircut-c": {
"$ref": "#/components/schemas/summary"
},
"indianstockhaircut-f": {
"$ref": "#/components/schemas/summary"
},
"indianstockhaircut-s": {
"$ref": "#/components/schemas/summary"
},
"initmarginreq": {
"$ref": "#/components/schemas/summary"
},
"initmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"initmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"initmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"leverage": {
"$ref": "#/components/schemas/summary"
},
"leverage-c": {
"$ref": "#/components/schemas/summary"
},
"leverage-f": {
"$ref": "#/components/schemas/summary"
},
"leverage-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadavailablefunds": {
"$ref": "#/components/schemas/summary"
},
"lookaheadavailablefunds-c": {
"$ref": "#/components/schemas/summary"
},
"lookaheadavailablefunds-f": {
"$ref": "#/components/schemas/summary"
},
"lookaheadavailablefunds-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadexcessliquidity": {
"$ref": "#/components/schemas/summary"
},
"lookaheadexcessliquidity-c": {
"$ref": "#/components/schemas/summary"
},
"lookaheadexcessliquidity-f": {
"$ref": "#/components/schemas/summary"
},
"lookaheadexcessliquidity-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadinitmarginreq": {
"$ref": "#/components/schemas/summary"
},
"lookaheadinitmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"lookaheadinitmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"lookaheadinitmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadmaintmarginreq": {
"$ref": "#/components/schemas/summary"
},
"lookaheadmaintmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"lookaheadmaintmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"lookaheadmaintmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"lookaheadnextchange": {
"$ref": "#/components/schemas/summary"
},
"maintmarginreq": {
"$ref": "#/components/schemas/summary"
},
"maintmarginreq-c": {
"$ref": "#/components/schemas/summary"
},
"maintmarginreq-f": {
"$ref": "#/components/schemas/summary"
},
"maintmarginreq-s": {
"$ref": "#/components/schemas/summary"
},
"netliquidation": {
"$ref": "#/components/schemas/summary"
},
"netliquidation-c": {
"$ref": "#/components/schemas/summary"
},
"netliquidation-f": {
"$ref": "#/components/schemas/summary"
},
"netliquidation-s": {
"$ref": "#/components/schemas/summary"
},
"netliquidationuncertainty": {
"$ref": "#/components/schemas/summary"
},
"nlvandmargininreview": {
"$ref": "#/components/schemas/summary"
},
"pasharesvalue": {
"$ref": "#/components/schemas/summary"
},
"pasharesvalue-c": {
"$ref": "#/components/schemas/summary"
},
"pasharesvalue-f": {
"$ref": "#/components/schemas/summary"
},
"pasharesvalue-s": {
"$ref": "#/components/schemas/summary"
},
"postexpirationexcess": {
"$ref": "#/components/schemas/summary"
},
"postexpirationexcess-c": {
"$ref": "#/components/schemas/summary"
},
"postexpirationexcess-f": {
"$ref": "#/components/schemas/summary"
},
"postexpirationexcess-s": {
"$ref": "#/components/schemas/summary"
},
"postexpirationmargin": {
"$ref": "#/components/schemas/summary"
},
"postexpirationmargin-c": {
"$ref": "#/components/schemas/summary"
},
"postexpirationmargin-f": {
"$ref": "#/components/schemas/summary"
},
"postexpirationmargin-s": {
"$ref": "#/components/schemas/summary"
},
"previousdayequitywithloanvalue": {
"$ref": "#/components/schemas/summary"
},
"previousdayequitywithloanvalue-c": {
"$ref": "#/components/schemas/summary"
},
"previousdayequitywithloanvalue-f": {
"$ref": "#/components/schemas/summary"
},
"previousdayequitywithloanvalue-s": {
"$ref": "#/components/schemas/summary"
},
"segmenttitle-c": {
"$ref": "#/components/schemas/summary"
},
"segmenttitle-f": {
"$ref": "#/components/schemas/summary"
},
"segmenttitle-s": {
"$ref": "#/components/schemas/summary"
},
"totalcashvalue": {
"$ref": "#/components/schemas/summary"
},
"totalcashvalue-c": {
"$ref": "#/components/schemas/summary"
},
"totalcashvalue-f": {
"$ref": "#/components/schemas/summary"
},
"totalcashvalue-s": {
"$ref": "#/components/schemas/summary"
},
"totaldebitcardpendingcharges": {
"$ref": "#/components/schemas/summary"
},
"totaldebitcardpendingcharges-c": {
"$ref": "#/components/schemas/summary"
},
"totaldebitcardpendingcharges-f": {
"$ref": "#/components/schemas/summary"
},
"totaldebitcardpendingcharges-s": {
"$ref": "#/components/schemas/summary"
},
"tradingtype-f": {
"$ref": "#/components/schemas/summary"
},
"tradingtype-s": {
"$ref": "#/components/schemas/summary"
}
}
}
}
}
}
}
}
}
},
"components": {
"requestBodies": {
"Body": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"acctIds": {
"type": "array",
"items": {
"type": "string",
"description": "account id"
}
}
}
}
}
},
"description": "an array of account ids",
"required": true
}
},
"schemas": {
"futures": {
"type": "array",
"items": {
"type": "object",
"description": "future contract information",
"properties": {
"symbol": {
"type": "string"
},
"conid": {
"type": "integer",
"description": "conid of the future contract"
},
"underlyingConid": {
"type": "integer"
},
"expirationDate": {
"type": "string"
},
"ltd": {
"type": "string",
"description": "last trading day"
}
}
}
},

	    "summary": {
            "type": "object",
            "description": "account information",
            "properties": {
                "total": {
                    "type": "object",
                    "properties": {
                        "chg": {
                            "type": "string",
                            "description": "total change amount"
                        },
                        "rtn": {
                            "type": "string",
                            "description": "change percent"
                        },
                        "incompleteData": {
                            "type": "boolean",
                            "description": "set to true if any external account data is not available for starting or ending date, resulting in potentially unusual total values."
                        },
                        "endVal": {
                            "type": "string"
                        },
                        "startVal": {
                            "type": "string"
                        }
                    }
                },
                "startDate": {
                    "type": "string",
                    "description": "date format-- yyyy-MM-dd"
                },
                "excludedAccounts": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "lastUpdateAttempt": {
                                "type": "string"
                            },
                            "fiName": {
                                "type": "string"
                            },
                            "acctTitle": {
                                "type": "string"
                            },
                            "acctNumAtFI": {
                                "type": "string"
                            },
                            "acctId": {
                                "type": "string"
                            },
                            "lastUpdate": {
                                "type": "string"
                            },
                            "harvestCode": {
                                "type": "integer"
                            },
                            "lastUpdateStatusCode": {
                                "type": "string"
                            },
                            "rc": {
                                "type": "integer"
                            }
                        }
                    }
                },
                "lastSuccessfulUpdate": {
                    "type": "string"
                },
                "accountSummaries": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "chg": {
                                "type": "string"
                            },
                            "hasAccounts": {
                                "type": "string"
                            },
                            "accountTypeName": {
                                "type": "string"
                            },
                            "rtn": {
                                "type": "string"
                            },
                            "endVal": {
                                "type": "string"
                            },
                            "accountTypeCode": {
                                "type": "string"
                            },
                            "startVal": {
                                "type": "string"
                            }
                        }
                    }
                },
                "endDate": {
                    "type": "string"
                },
                "hasExternalAccounts": {
                    "type": "boolean",
                    "description": "indicator of user having configured any external accounts"
                },
                "rc": {
                    "type": "integer"
                },
                "currency": {
                    "type": "string"
                },
                "userId": {
                    "type": "string"
                },
                "pm": {
                    "type": "string"
                },
                "view": {
                    "type": "string"
                },
                "balanceByDate": {
                    "type": "object",
                    "properties": {
                        "series": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "groupId": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "date": {
                                        "type": "array",
                                        "items": {
                                            "type": "array",
                                            "items": {
                                                "type": "number"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

	}
}

}
'''

self.make_request() causing an attribute error because it doesn't have the right response codes

 

For a particular endpoint, my json contract has the following responses:

 
responses

But the corresponding make_request function, which was created by the generate command, only handles a 200 response code:

 
return

Because of this, I'm getting the following attribute error:

image

Manually including the response codes fixes the issue, but I would assume there's an error in the generate command .

another class None and schema names containing - produce invalid python

sample below illustrates the issue.
the sample also creates an issue with post__v1_portal_iserver_secdef_search (another class None) - not sure why
perhaps because the type is object, with no definition of object...

'''
{
"openapi": "3.0.0",
"info": {
"title": "Client Portal Web API",
"description": "Production version of the Client Portal Web API",
"version": "1.0.0"
},
"paths": {
"/iserver/secdef/search": {
"post": {
"summary": "Search by symbol or name",
"tags": [
"Contract"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"symbol"
],
"properties": {
"symbol": {
"type": "string",
"description": "symbol or name to be searched"
},
"name": {
"type": "boolean",
"description": "should be true if the search is to be performed by name. false by default."
},
"secType": {
"type": "string",
"description": "If search is done by name, only the assets provided in this field will be returned. Currently, only STK is supported."
}
}
}
}
},
"description": "symbol or name to be searched",
"required": true
},
"responses": {
"200": {
"description": "returns an array of results",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"conid": {
"type": "integer"
},
"companyHeader": {
"type": "string"
},
"companyName": {
"type": "string"
},
"symbol": {
"type": "string"
},
"description": {
"type": "string"
},
"opt": {
"type": "string"
},
"war": {
"type": "string"
},
"sections": {
"type": "array",
"items": {
"type": "object"
}
}
}
}
}
}
}
},
"500": {
"description": "error while processing the request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
}
}
}
}
}
}
},

        "/iserver/account": {
        "post": {
            "summary": "Updates currently selected account to the provided account",
            "description": "If an user has multiple accounts, and user wants to get orders, trades, etc. of an account other than currently selected account, then user can update the currently selected account using this API and then can fetch required information for the newly updated account.",
            "tags": [
                "Account"
            ],
            "requestBody": {
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/set-account"
                        }
                    }
                },
                "description": "account id",
                "required": true
            },
            "responses": {
                "200": {
                    "description": "an object containing updated account ID",
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "set": {
                                        "type": "boolean"
                                    },
                                    "acctId": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

},
"servers": [
    {
        "url": "https://localhost:5000/v1/portal"
    }
],
"components": {
    "requestBodies": {
        "Body": {
            "content": {
                "application/json": {
                    "schema": {
                        "type": "object",
                        "properties": {
                            "acctIds": {
                                "type": "array",
                                "items": {
                                    "type": "string",
                                    "description": "account id"
                                }
                            }
                        }
                    }
                }
            },
            "description": "an array of account ids",
            "required": true
        }
    },
    "schemas": {
	    "set-account": {
            "type": "object",
            "properties": {
                "acctId": {
                    "type": "string",
                    "description": "Account ID"
                }
            }
        },


    }
}

}
'''

request or response defines object inline instead of in separate schema ref - produces None class

the included json includes a few samples of this issue.
{ "openapi": "3.0.0", "info": { "title": "Client Portal Web API", "description": "Production version of the Client Portal Web API", "version": "1.0.0" }, "paths": { "/iserver/accounts": { "get": { "summary": "Brokerage Accounts", "description": "Returns a list of accounts the user has trading access to, their respective aliases and the currently selected account. Note this endpoint must be called before modifying an order or querying open orders.", "tags": [ "Account" ], "responses": { "200": { "description": "An array of accounts", "content": { "application/json": { "schema": { "type": "object", "properties": { "accounts": { "type": "array", "items": { "type": "string" }, "description": "Unique account id" }, "aliases": { "type": "object", "description": "Account Id and its alias" }, "selectedAccount": { "type": "string" } } } } } } } } }, "/iserver/marketdata/snapshot": { "get": { "summary": "Market Data", "description": "Get Market Data for the given conid(s). The end-point will return by default bid, ask, last, change, change pct, close, listing exchange.\nSee response fields for a list of available fields that can be request via fields argument.\nThe endpoint /iserver/accounts should be called prior to /iserver/marketdata/snapshot.\nTo receive all available fields the /snapshot endpoint will need to be called several times.\n", "tags": [ "Market_Data" ], "parameters": [ { "in": "query", "name": "conids", "description": "list of conids separated by comma", "required": true, "schema": { "type": "string" } }, { "in": "query", "name": "since", "description": "time period since which updates are required. uses epoch time with milliseconds.", "required": false, "schema": { "type": "integer" } }, { "in": "query", "name": "fields", "description": "list of fields separated by comma", "required": false, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Returns an array of objects", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "31": { "type": "string", "description": "Last Price" }, "55": { "type": "string", "description": "Symbol" } } } } } } }, "400": { "description": "sent when accounts are not queried before sending this request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" }, "statusCode": { "type": "integer" } } } } } } } } }, "/iserver/secdef/search": { "post": { "summary": "Search by symbol or name", "tags": [ "Contract" ], "requestBody": { "content": { "application/json": { "schema": { "type": "object", "required": [ "symbol" ], "properties": { "symbol": { "type": "string", "description": "symbol or name to be searched" }, "name": { "type": "boolean", "description": "should be true if the search is to be performed by name. false by default." }, "secType": { "type": "string", "description": "If search is done by name, only the assets provided in this field will be returned. Currently, only STK is supported." } } } } }, "description": "symbol or name to be searched", "required": true }, "responses": { "200": { "description": "returns an array of results", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "properties": { "conid": { "type": "integer" }, "sections": { "type": "array", "items": { "type": "object" } } } } } } } }, "500": { "description": "error while processing the request", "content": { "application/json": { "schema": { "type": "object", "properties": { "error": { "type": "string" } } } } } } } } }, "/iserver/scanner/params": { "get": { "summary": "get lists of available scanners", "description": "Returns an object contains four lists contain all parameters for scanners", "tags": [ "Scanner" ], "responses": { "200": { "description": "An object contains lists", "content": { "application/json": { "schema": { "type": "object", "properties": { "scan_type_list": { "type": "array", "items": { "type": "object", "properties": { "display_name": { "type": "string" }, "code": { } } }, "instrument_list": { "type": "array", "items": { "type": "object", "properties": { "display_name": { "type": "string" }, "type": { "type": "string" }, "filters": { "type": "array", "items": { "type": "string", "description": "code of filter" } } } } }, "filter_list": { "type": "array", "items": { "type": "object", "properties": { "group": { "type": "string" } } } }, "location_tree": { "type": "array", "items": { "type": "object", "properties": { "display_name": { "type": "string" }, "type": { "type": "string" }, "locations": { "type": "array", "items": { "type": "object", "properties": { "display_name": { "type": "string" }, "type": { "type": "string" } } } } } } } } } } } } } } }, }, "servers": [ { "url": "https://localhost:5000/v1/portal" } ], "components": { "requestBodies": { "Body": { "content": { "application/json": { "schema": { "type": "object", "properties": { "acctIds": { "type": "array", "items": { "type": "string", "description": "account id" } } } } } }, "description": "an array of account ids", "required": true } }, "schemas": { } } }

Literal not in typing.py

Apparently the answer is
python/typing#707
pip3 install typing_extensions and then use from typing_extensions import Literal.

might be useful to include something about this in the code?

setup.py file for client packaging

Hi! I like your project, and I think it would be good to add a simple packaging boilerplate to a generated client lib so that common packaging operations (python setup.py sdist bdist_wheel) can work out of the box. What would be the quickiest way to extend the library renderer for that purpose?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.