├── .babelrc ├── .gitignore ├── API.md ├── DEV.md ├── README.md ├── TODO.md ├── api ├── auth.yaml ├── body.yaml ├── endpoints.yaml ├── endpointsraw.txt ├── headers.yaml ├── instagram.yaml ├── parameters.yaml └── schemas.yaml ├── configs ├── javascript.yaml └── python.yaml ├── generators └── python.json ├── instagram-api.bundle.json ├── package.json ├── private-instagram-api-toolkit-sdk-banner.png ├── sdks ├── README.md └── python │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── api_test.py │ ├── docs │ ├── AuthApi.md │ ├── AuthBody.md │ ├── Error.md │ ├── JsonObject.md │ ├── User.md │ └── UserApi.md │ ├── git_push.sh │ ├── private_instagram_sdk │ ├── __init__.py │ ├── api │ │ ├── Auth.py │ │ ├── User.py │ │ └── __init__.py │ ├── api_client.py │ ├── configuration.py │ ├── exceptions.py │ ├── models │ │ ├── AuthBody.py │ │ ├── JsonObject.py │ │ ├── __init__.py │ │ ├── error.py │ │ └── user.py │ └── rest.py │ ├── requirements.txt │ ├── setup.py │ ├── test-requirements.txt │ ├── test │ ├── __init__.py │ ├── test_AuthBody.py │ ├── test_JsonObject.py │ ├── test_error.py │ └── test_user.py │ └── tox.ini ├── social-preview.png ├── templates └── python │ ├── .svn │ ├── entries │ ├── format │ ├── pristine │ │ ├── 15 │ │ │ └── 154b5d53626ded12251b78172ad3850a37e22844.svn-base │ │ ├── 20 │ │ │ └── 20db0342b0834a15b3dec124f5247aed1ff5210f.svn-base │ │ ├── 22 │ │ │ └── 2266be0be68af27ee0e4907a25ff11ab790f1aeb.svn-base │ │ ├── 27 │ │ │ └── 27320fa2f9d3d1e1fe9b7519f2cdd043d58d1011.svn-base │ │ ├── 32 │ │ │ └── 320ddb91c3753a832fe6126f9ff68a14808205e0.svn-base │ │ ├── 33 │ │ │ └── 33c3f6bdd61a1e47b0997f090947c24e078067ab.svn-base │ │ ├── 39 │ │ │ └── 39ccaca79c80a925989378c2cfc479e6fc04767b.svn-base │ │ ├── 44 │ │ │ └── 444eae2c62f2edda2a8595d7d28d920df1f395be.svn-base │ │ ├── 64 │ │ │ └── 644cc5eef2cf5ebdaf661549afefdc4c08e505bd.svn-base │ │ ├── 66 │ │ │ └── 6688bb6debacfb5d9b2430e5caf5ef73ea265a46.svn-base │ │ ├── 87 │ │ │ └── 87b870d25d2c7c8b11f53bf6626fa63ee323b525.svn-base │ │ ├── 1c │ │ │ └── 1c9724edf83806c9ae7a7185e12006bc28f477cb.svn-base │ │ ├── 2a │ │ │ └── 2acf5085b6ced6e12cd5c8ea4610131dc705d936.svn-base │ │ ├── 3c │ │ │ └── 3c722373f8d283d1868b930574cb613d930cba52.svn-base │ │ ├── 3d │ │ │ └── 3dbcb7d62227b54eae49fc82a65a12e9965c5e64.svn-base │ │ ├── 4c │ │ │ └── 4cadcb4e662b69f0b7a56cc93c290c3a22c97e7c.svn-base │ │ ├── 7c │ │ │ ├── 7c794a2875e06348f348641a7d8e5368395e7d82.svn-base │ │ │ └── 7c80061b88ec974c0ff6cbe63d96d9194d9c0c57.svn-base │ │ ├── a0 │ │ │ ├── a024a63764228ea9af15cc0bdaaff0363ae84731.svn-base │ │ │ └── a0e98ebbdda8c89351e676f19cc7cdb35d3df25d.svn-base │ │ ├── a2 │ │ │ └── a222aaf5e2fc5faf5dc972c903c8fee690e025e8.svn-base │ │ ├── ac │ │ │ └── ac90754da11973e732a6c00968d60dfad619f64f.svn-base │ │ ├── ae │ │ │ └── aedf29ef75f86b9c04518157f282d7c7990b66f4.svn-base │ │ ├── bb │ │ │ └── bbc24d7155c02c1875a8317fba7b9d048c9b35be.svn-base │ │ ├── c3 │ │ │ └── c3bc189fb655678f52c27e95f97b79e067b818c1.svn-base │ │ ├── da │ │ │ └── da39a3ee5e6b4b0d3255bfef95601890afd80709.svn-base │ │ ├── ed │ │ │ └── ed083d2a05780b50c2ed0d04bce680cd910f6e0d.svn-base │ │ ├── f3 │ │ │ └── f3f6c7f3eda230aa494c94f03959162143250ff3.svn-base │ │ └── fc │ │ │ └── fcfbd803ba2659232ce666fb6d5a172ebde2fe12.svn-base │ ├── wc.db │ └── wc.db-journal │ ├── README.mustache │ ├── README_onlypackage.mustache │ ├── __init__api.mustache │ ├── __init__model.mustache │ ├── __init__package.mustache │ ├── __init__test.mustache │ ├── api.mustache │ ├── api_client.mustache │ ├── api_doc.mustache │ ├── api_doc_example.mustache │ ├── api_test.mustache │ ├── common_README.mustache │ ├── configuration.mustache │ ├── exceptions.mustache │ ├── git_push.sh.mustache │ ├── gitignore.mustache │ ├── model.mustache │ ├── model_doc.mustache │ ├── model_test.mustache │ ├── partial_header.mustache │ ├── python_doc_auth_partial.mustache │ ├── requirements.mustache │ ├── rest.mustache │ ├── setup.mustache │ ├── test-requirements.mustache │ ├── tox.mustache │ └── travis.mustache ├── test └── python-sdk.py ├── toolkit.build.js ├── toolkit.js ├── tools ├── auto_generate_sdks.sh └── example_login.py └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "corejs": "3", 7 | "useBuiltIns": "usage" 8 | } 9 | ], 10 | ], 11 | } 12 | 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /API.md: -------------------------------------------------------------------------------- 1 | # API Endpoints 2 | 3 | ## Table Example 4 | 5 | This is an example of a table of endpoints, use this as a reference. 6 | 7 | | METHOD | Endpoint | Parameters | Description | 8 | | ------ | -------- | ---------- | --- | 9 | | **GET** | /path/to | par1, par2, test | Description for this endpoint explaining the action it does | 10 | 11 | > 12 | Following there are all endpoints with method and parameters. 13 | The tables will explain for itself, just read the description to understand what is the endpoint's action it does. 14 | 15 | ## Auth Flow and API requests 16 | 17 | The auth flow is simple, it will generate a token that you will use in every request done to private api. 18 | Doing a **POST** request to `/api/v1/accounts/login` with its parameters (check the table below, it's the first endpoint). 19 | 20 | *Every* request need a modified `Headers`. 21 | Check the file [login.py](https://github.com/reliefs/instagramapi/blob/master/login.py) 22 | 23 | ### account Endpoints 24 | 25 | | METHOD | Endpoint | Parameters | Description | 26 | | ------ | -------- | ---------- | --- | 27 | | **POST** | /accounts/login | device_id, guid, adid, phone_id, _csrftoken, username, password, login_attempt_count: '0' | | 28 | | **POST** | /accounts/edit_profile | username, gender: int(gender), phone_number, first_name, biography, external_url, email | | 29 | | **POST** | /accounts/change_profile_picture | photo_data: string of image | | 30 | | **POST** | /accounts/remove_profile_picture | | | 31 | | **POST** | /accounts/current_user | | | 32 | | **POST** | /accounts/set_private | | | 33 | | **POST** | /accounts/set_public | | | 34 | | **POST** | /accounts/logout | phone_id, _csrftoken, guid, device_id, _uuid | | 35 | 36 | ### Upload/configure Media Endpoints 37 | 38 | | METHOD | Endpoint | Parameters | Description | 39 | | ------ | -------- | ---------- | --- | 40 | | **POST** | /upload/photo | | | 41 | | **POST** | /upload/video | | | 42 | 43 | ### Configure Media Endpoints 44 | 45 | | METHOD | Endpoint | Parameters | Description | 46 | | ------ | -------- | ---------- | --- | 47 | | **POST** | /media/configure | caption, | | 48 | | **POST** | /media/configure_to_story | | | 49 | | **POST** | /media/configure_sidecar | | | 50 | 51 | ### collections 52 | 53 | | METHOD | Endpoint | Parameters | Description | 54 | | ------ | -------- | ---------- | --- | 55 | | **GET** | /feed/collection/{collection-id}/ | | | 56 | | **GET** | /collections/{collection-id}/edit | | | 57 | | **GET** | /collections/{collection-id}/delete | | | 58 | 59 | ### Discover Endpoints 60 | 61 | | METHOD | Endpoint | Parameters | Description | 62 | | ------ | -------- | ---------- | --- | 63 | | **GET** | /discover | | | 64 | | **GET** | /discover/channels_home | | | 65 | | **GET** | /discover/chaining | | | 66 | | **GET** | /discover/top_live | | | 67 | | **GET** | /discover/top_live_status | | | 68 | 69 | ### Feed Endpoints 70 | 71 | | METHOD | Endpoint | Parameters | Description | 72 | | ------ | -------- | ---------- | --- | 73 | | **GET** | /feed | | | 74 | | **GET** | /feed/liked | | | 75 | | **GET** | /feed/saved | | | 76 | | **GET** | /feed/only_me_feed | | | 77 | | **GET** | /feed/timeline | | | 78 | | **GET** | /feed/popular | | | 79 | | **GET** | /feed/reels_tray | | | 80 | | **GET** | /feed/reels_media | | | 81 | | **GET** | /feed/tag/{tag} | | | 82 | | **GET** | /feed/location/{location-id} | | | 83 | | **GET** | /feed/user/{user-id} | | | 84 | | **GET** | /feed/user/{user-name}/username | | | 85 | | **GET** | /feed/user/{user-id}/reel_media | | | 86 | | **GET** | /feed/user/{user-id}/story | | | 87 | 88 | ### Friendships endpoints 89 | 90 | | METHOD | Endpoint | Parameters | Description | 91 | | ------ | -------- | ---------- | --- | 92 | | **GET** | /friendships | | | 93 | | **GET** | /friendships/autocomplete_user_list | | | 94 | | **GET** | /friendships/{user-id}/following | | | 95 | | **GET** | /friendships/{user-id}/following | | | 96 | | **GET** | /friendships/pending | | | 97 | | **GET** | /friendships/show/{user-id} | | | 98 | | **GET** | /friendships/show_many | | | 99 | | **GET** | /friendships/create/{user-id} | | | 100 | | **GET** | /friendships/destroy/{user-id} | | | 101 | | **GET** | /friendships/block/{user-id} | | | 102 | | **GET** | /friendships/unblock/{user-id} | | | 103 | | **GET** | /friendships/block_friend_reel/{user-id} | | | 104 | | **GET** | /friendships/unblock_friend_reel/{user-id} | | | 105 | | **GET** | /friendships/set_reel_block_status | | | 106 | | **GET** | /friendships/blocked_reels | | | 107 | | **GET** | /friendships/favorite/{user-id} | | | 108 | | **GET** | /friendships/unfavorite/{user-id} | | | 109 | | **GET** | /friendships/ignore/{user-id} | | | 110 | | **GET** | /friendships/remove_follower/{user-id} | | | 111 | 112 | ### For endpoints in ``/highlights/`` or related to the highlights feature 113 | 114 | | METHOD | Endpoint | Parameters | Description | 115 | | ------ | -------- | ---------- | --- | 116 | | **GET** | /highlights | | | 117 | | **GET** | /highlights/create_reel | | | 118 | | **GET** | /highlights/{user-id}/highlights_tray | | | 119 | | **GET** | /highlights/{highlight-id}/edit_reel | | | 120 | | **GET** | /highlights/{highlight-id}/delete_reel | | | 121 | 122 | ### For endpoints in ``/igtv/`` 123 | 124 | | METHOD | Endpoint | Parameters | Description | 125 | | ------ | -------- | ---------- | --- | 126 | | **GET** | /igtv/channel | | | 127 | | **GET** | /igtv/search | | | 128 | | **GET** | /igtv/tv_guide | | | 129 | 130 | ### For endpoints in ``/live/`` 131 | 132 | | METHOD | Endpoint | Parameters | Description | 133 | | ------ | -------- | ---------- | --- | 134 | | **GET** | /live/get_suggested_broadcasts | | | 135 | | **GET** | /live/{broadcast-id}/info | | | 136 | | **GET** | /live/{broadcast-id}/like | | | 137 | | **GET** | /live/{broadcast-id}/comment | | | 138 | | **GET** | /live/{broadcast-id}/get_comment | | | 139 | | **GET** | /live/{broadcast-id}/get_like_count | | | 140 | | **GET** | /live/{broadcast-id}/get_post_live_likes | | | 141 | | **GET** | /live/{broadcast-id}/get_post_live_comments | | | 142 | | **GET** | /live/{broadcast-id}/heartbeat_and_get_viewer_count | | | 143 | 144 | ### For endpoints related to location functionality 145 | 146 | | METHOD | Endpoint | Parameters | Description | 147 | | ------ | -------- | ---------- | --- | 148 | | **GET** | /locations/{location-id}/info | | | 149 | | **GET** | /locations/{location-id}/related | | | 150 | | **GET** | /locations/{location-id}/sections | | | 151 | 152 | ### For endpoints in ``/media/`` 153 | 154 | | METHOD | Endpoint | Parameters | Description | 155 | | ------ | -------- | ---------- | --- | 156 | | **GET** | /media/seen | | | 157 | | **GET** | /media/{story-pk}/list_reel_media_viewer | | | 158 | | **GET** | /media/{comment-id}/comment_like | | | 159 | | **GET** | /media/{comment-id}/comment_unlike | | | 160 | | **GET** | /media/{comment-id}/comment_likers | | | 161 | | **GET** | /media/{media-id}/{only_me} | | | 162 | | **GET** | /media/{media-id}/info | | | 163 | | **GET** | /media/{media-id}/infos | | | 164 | | **GET** | /media/{media-id}/like | | | 165 | | **GET** | /media/{media-id}/unlike | | | 166 | | **GET** | /media/{media-id}/likers | | | 167 | | **GET** | /media/{media-id}/likers_chrono | | | 168 | | **GET** | /media/{media-id}/save | | | 169 | | **GET** | /media/{media-id}/unsave | | | 170 | | **GET** | /media/{media-id}/permalink | | | 171 | | **GET** | /media/{media-id}/edit_media | | | 172 | | **GET** | /media/{media-id}/delete | | | 173 | | **GET** | /media/{media-id}/enable_comments | | | 174 | | **GET** | /media/{media-id}/disable_comments | | | 175 | | **GET** | /media/{media-id}/comment | | | 176 | | **GET** | /media/{media-id}/comment/bulk_delete | | | 177 | | **GET** | /media/{media-id}/comment/{comment-id}/child_comments | | | 178 | | **GET** | /media/{media-id}/comments | | | 179 | | **GET** | /media/{media-id}/comments/{comment-id}/child_comments | | | 180 | | **GET** | /media/{media-id}/comments/{comment-id}/inline_child_comments | | | 181 | 182 | ### For miscellaneous functions 183 | 184 | | METHOD | Endpoint | Parameters | Description | 185 | | ------ | -------- | ---------- | --- | 186 | | **GET** | /qe/expose | | | 187 | | **GET** | /oembed | | | 188 | | **GET** | /news | | | 189 | | **GET** | /news/inbox | | | 190 | | **GET** | /language/bulk_translate | | | 191 | | **GET** | /fbsearch/topsearch | | | 192 | | **GET** | /direct_v2/ranked_recipients | | | 193 | | **GET** | /direct_share/recent_recipients | | | 194 | 195 | ### For endpoints in ``/tags/`` 196 | 197 | | METHOD | Endpoint | Parameters | Description | 198 | | ------ | -------- | ---------- | --- | 199 | | **GET** | /tags/sarch | | | 200 | | **GET** | /tags/suggested | | | 201 | | **GET** | /tags/follow/{hashtag} | | | 202 | | **GET** | /tags/unfollow/{hashtag} | | | 203 | | **GET** | /tags/{tag}/info | | | 204 | | **GET** | /tags/{tag}/related | | | 205 | | **GET** | /tags/{tag}/sections | | | 206 | 207 | ### For endpoints in ``/users/`` 208 | 209 | | METHOD | Endpoint | Parameters | Description | 210 | | ------ | -------- | ---------- | --- | 211 | | **GET** | /users/self | | | 212 | | **GET** | /users/search | | | 213 | | **GET** | /users/check_username | | | 214 | | **GET** | /users/blocked_list | | | 215 | | **GET** | /users/reel_settings | | | 216 | | **GET** | /users/set_reel_settings | | | 217 | | **GET** | /users/{user-id}/info | | | 218 | | **GET** | /users/{user-id}/full_detail_info | | | 219 | | **GET** | /users/{user-name}/usernameinfo | | | 220 | 221 | ### For endpoints in ``/usertags/`` 222 | 223 | | METHOD | Endpoint | Parameters | Description | 224 | | ------ | -------- | ---------- | --- | 225 | | **GET** | /usertags/{user-id}/feed | | | 226 | | **GET** | /usertags/{media-id}/remove | | | 227 | -------------------------------------------------------------------------------- /DEV.md: -------------------------------------------------------------------------------- 1 | # Developers only (contributors) 2 | 3 | ## Contribute to this project 4 | 5 | If you want to contribute to this (**huge**) project, you can: 6 | 7 | - **UPDATE** and **Mantain** the endpoints/params in [*API.md*](/API.md) and in [*api/instagram.yaml* schema](/api/instagram.yaml) 8 | - **ADD** more configs helper to generate more SDKs 9 | - **GENERATE** new and update existing SDKs already released 10 | - **CONTRIBUTE** creating documentations, tools, issues, generators, sdks and more 11 | 12 | --- 13 | 14 | ## Prepare your environment 15 | 16 | If you want to contribute to this project there are some things you have to do before start pushing your commits. 17 | 18 | Make sure you have on your system this packages/libs/tools: 19 | 20 | - git 21 | - NodeJS + npm 22 | - yarn 23 | - Python (v3.7 is suggested but *any* version will be fine) 24 | 25 | ## Quickstart 26 | 27 | 1. First you need to `git clone` this repo. 28 | 2. After that you need to install some node/npm packages running: `yarn install` inside this folder 29 | 3. Now you can start using the package command like `yarn generate` or `yarn viewer` 30 | 31 | ## Following 32 | 33 | ### toolkit 34 | 35 | If you run the `toolkit` automatically will start a wizard that will help contributors from the creation of a new configuration files to the code generation of a new sdk, just run the command: 36 | 37 | ```sh 38 | yarn toolkit 39 | ``` 40 | 41 | ### Create a NEW sdk -- ^^ use the `toolkit` instead ^^ 42 | 43 | If you want to create a new sdk using the openapi-codegen you need to follow this mini-tutorial: 44 | 45 | 1. Create a new config inside the *./generators* folder with command `openapi-generator config-help -g GENERATOR_NAME` 46 | 1. if you want to copy all CONFIG OPTIONS inside the file and then edit it, you can run the command `openapi-generator config-help -g GENERATOR_NAME >> ./configs/GENERATOR_NAME.yaml` 47 | 2. another option is to use the toolkit and the file will be auto-formatted in yaml syntax with `yarn toolkit` and follow the wizard (WIP) 48 | 49 | If you want to create a new sdk using the openapi-generator you need to follow this mini-tutorial: 50 | 51 | 1. Check the generator you want to use and keep its name in mind (you can find a list here > [OpenAPI Generator - Generators List](https://openapi-generator.tech/docs/generators)) 52 | 2. Create a new config inside the *./configs* folder including the options from the command `openapi-generator config-help -g GENERATOR_NAME` 53 | 1. if you want to copy all CONFIG OPTIONS inside the file and then edit it, you can run the command `openapi-generator config-help -g GENERATOR_NAME >> ./configs/GENERATOR_NAME.yaml` 54 | 2. another option is to use the toolkit and the file will be auto-formatted in yaml syntax with `yarn toolkit` and follow the wizard (WIP) 55 | 56 | --- 57 | 58 | ## Resources 59 | 60 | ### **Useful resources for endpoints and parameters** 61 | 62 | - https://github.com/ping/instagram_private_api/blob/master/COMPAT.md 63 | - https://github.com/ping/instagram_private_api/tree/master/instagram_private_api/endpoints 64 | - https://github.com/mgp25/Instagram-API/blob/master/src/Instagram.php 65 | - https://github.com/dilame/instagram-private-api/tree/master/src 66 | 67 | ### **OLD** swagger 2.0 version of the public instagram api 68 | 69 | An old version of the public instagram api, as a swagger 2.0 yaml is here: 70 | https://github.com/apiaryio/swagger-zoo/blob/master/fixtures/examples/swagger/instagram.yaml -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | # instagram-api-toolkit 4 | 5 | ![Private Instagram API toolkit](private-instagram-api-toolkit-sdk-banner.png) 6 | 7 | 8 | 9 |
10 | 11 | ### Use the library 12 | 13 | If you want to get access to the **instagram private api** you need to download the sdk depending on the language/framework you are using, here you can find the sdks available (open the spoiler below). 14 | 15 | List of SDK for Instagram Private API 16 | 17 | | Language/Framework | Package | Install or Download | 18 | | --- | --- | --- | 19 | | python | [private_instagram_sdk](sdks/python) | *Not published on PyPi* 20 | 21 | **(more on >> [Instagram Private API SDKs](/sdks))** 22 | 23 | ### Explain the idea 24 | 25 | If you are a coder/programmer/developer and you want to access to the instagram api you already know that this is "not" possible, unless you use the public api, because the private api is only accessible from the Instagram mobile app. 26 | 27 | But **probably** you also know that someone can fake all parts of a request to an API so it's also possible to make Instagram think that our api calls are sended from his mobile app. 28 | Already there are many library that are trying to do just that, fake itself as an instagram mobile app and send login and other requests to the instagram private api. 29 | 30 | *So* the idea was to create a **single source of truth** ([SSOT](https://en.wikipedia.org/wiki/Single_source_of_truth)) and keep in mind various principles of software design and software development like [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) and [KISS](https://en.wikipedia.org/wiki/KISS_principle). 31 | 32 | ### API design process 33 | 34 | To define a SSoT there is the needing of a standard to use and there isn't a better way to create a schema than using the [OpenAPI Specification v3](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md). 35 | 36 | To inspect the actual schema you can just go to the folder [/api](/api) and see all schema's files. 37 | 38 | --- 39 | 40 | ## Goal 41 | 42 | To accomplish the goal: 43 | 44 | 1. We need to define a schema of the private instagram api using the [OpenAPI Specs](https://github.com/OAI/OpenAPI-Specification). 45 | 46 | 2. Then we can use this language-agnostic schema to generate automatically an SDK/Client for every language or framework we want (unless we have generators we can create the SDK) using a [OpenAPI Generators](https://openapi-generator.tech/docs/generators) or [OpenAPI Codegen](https://github.com/Mermade/openapi-codegen). 47 | 48 | --- 49 | 50 | ## Contribute to this project 51 | 52 | If you want to be part of the contributors of this project, read the instructions in [DEV.md](/DEV.md). 53 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | 3 | The main plan is to create the schema and extend it or update it in future time then release sdk/client-api packages for supported languages. 4 | 5 | ## PLAN 6 | 7 | ### A. The Schema 8 | 9 | 1. API.md 10 | 1. [x] list all endpoints 11 | 2. [ ] list all method for endpoints (add a simple GET, POST, DELETE, PUT near the endpoint) 12 | 3. [ ] list all parameters used in endpoints 13 | 2. instagram.yaml 14 | 1. [ ] set correct server url 15 | 2. [ ] reference parameters to parameters.yaml 16 | 3. [ ] setup `security` for login user to instagram and get token 17 | 4. [ ] add all endpoints in form: 18 | 19 | > GET 20 | 21 | ```yaml 22 | /path/of/thing: 23 | get: 24 | parameters: $ref '#/parameters.yaml#thing-id' 25 | ``` 26 | > POST 27 | 28 | ```yaml 29 | /path/of/thing: 30 | post: 31 | parameters: $ref '#/parameters.yaml#thing-id' 32 | ``` 33 | 34 | ### B. The SDK(s) 35 | 36 | 1. [ ] explore all the generators avaible from openapi-generators.tech 37 | 2. [ ] deploy the first auto-generated sdk for the instagram private api 38 | 3. [ ] test the beta python package 39 | 40 | ### C. Enjoy 41 | 42 | > It speaks for itself -------------------------------------------------------------------------------- /api/auth.yaml: -------------------------------------------------------------------------------- 1 | cookieAuth: 2 | type: apiKey 3 | in: cookie 4 | name: csrftoken -------------------------------------------------------------------------------- /api/body.yaml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Request Body # 3 | ################################################################################ 4 | # Documentation link 5 | # https://swagger.io/docs/specification/describing-request-body/ 6 | 7 | authData: 8 | description: Optional description in *Markdown* 9 | required: true 10 | content: 11 | # application/json: 12 | # schema: 13 | # $ref: '#/components/schemas/Pet' 14 | # application/xml: 15 | # schema: 16 | # $ref: '#/components/schemas/Pet' 17 | application/x-www-form-urlencoded: 18 | schema: 19 | $ref: './schemas.yaml#/schemas/AuthBody' 20 | # text/plain: 21 | # schema: 22 | # type: string 23 | 24 | # ig_sig_key_version: 25 | # in: query 26 | # name: ig_sig_key_version 27 | # schema: 28 | # type: string 29 | # required: true 30 | # description: > 31 | # the password to use for authentication 32 | # signed_body: 33 | # in: query 34 | # name: signed_body 35 | # schema: 36 | # type: string 37 | # required: true 38 | # description: > 39 | # the password to use for authentication 40 | -------------------------------------------------------------------------------- /api/endpoints.yaml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Endpoints # 3 | ################################################################################ 4 | # Documentation link 5 | # https://swagger.io/docs/specification/paths-and-operations/ 6 | 7 | # DEMO Endpoints, for example 8 | # /path/to/: 9 | # post: 10 | # operationId: 'funcName' 11 | # tags: 12 | # it will be used to define a class, so you can call this endpoint like this >> ClassApi.funcName() 13 | # - Class 14 | # summary: summary description 15 | # description: Complete description of this endpoint and its capabilities 16 | # parameters: 17 | # - $ref: './parameters.yaml#/ua' 18 | # requestBody: 19 | # $ref: './body.yaml#/authData' 20 | # security: 21 | # - cookieAuth: [] 22 | # responses: 23 | # 200: 24 | # description: Successfully login the user 25 | # content: 26 | # application/json: 27 | # schema: 28 | # $ref: './schemas.yaml#/schemas/JsonObject' 29 | # 400: 30 | # description: Missing parameters 31 | # content: 32 | # application/json: 33 | # schema: 34 | # $ref: './schemas.yaml#/schemas/Error' 35 | # default: 36 | # description: Unexpected error 37 | # content: 38 | # application/json: 39 | # schema: 40 | # $ref: './schemas.yaml#/schemas/Error' 41 | 42 | 43 | # ACCOUNTS endpoints 44 | 45 | /accounts/login/: 46 | post: 47 | operationId: 'login' 48 | tags: 49 | - Auth 50 | summary: Login user to Instagram 51 | description: Login to Instagram with username/password 52 | requestBody: 53 | $ref: './body.yaml#/authData' 54 | security: 55 | - cookieAuth: [] 56 | responses: 57 | 200: 58 | description: Successfully login the user 59 | content: 60 | application/json: 61 | schema: 62 | $ref: './schemas.yaml#/schemas/JsonObject' 63 | 400: 64 | description: Missing parameters 65 | content: 66 | application/json: 67 | schema: 68 | $ref: './schemas.yaml#/schemas/Error' 69 | default: 70 | description: Unexpected error 71 | content: 72 | application/json: 73 | schema: 74 | $ref: './schemas.yaml#/schemas/Error' 75 | # /accounts/edit_profile: 76 | # /accounts/change_profile_picture: 77 | # /accounts/remove_profile_picture: 78 | # /accounts/current_user: 79 | # /accounts/set_private: 80 | # /accounts/set_public: 81 | # /accounts/logout: 82 | 83 | # USERS endpoints 84 | 85 | /users/{user_id}/info/: 86 | get: 87 | operationId: 'getUser' 88 | tags: 89 | - User 90 | summary: User Profile 91 | description: The User Profile endpoint returns information about the Instagram user 92 | that has authorized with the application. 93 | parameters: 94 | - $ref: './parameters.yaml#/user-id' 95 | responses: 96 | 200: 97 | description: Profile information for a user 98 | content: 99 | application/json: 100 | schema: 101 | $ref: './schemas.yaml#/schemas/User' 102 | default: 103 | description: Unexpected error 104 | content: 105 | application/json: 106 | schema: 107 | $ref: './schemas.yaml#/schemas/Error' 108 | # /users/search: 109 | # /users/check_username: 110 | # /users/blocked_list: 111 | # /users/reel_settings: 112 | # /users/set_reel_settings: 113 | # /users/{user-id}/info: 114 | # /users/{user-id}/full_detail_info: 115 | # /users/{user-name}/usernameinfo: 116 | 117 | # UPLOAD endpoints 118 | 119 | # /upload/photo: 120 | # /upload/video: 121 | 122 | # MEDIA endpoints 123 | 124 | # /media/configure: 125 | # /media/configure_to_story: 126 | # /media/configure_sidecar: 127 | # /media/seen: 128 | # /media/{story-pk}/list_reel_media_viewer: 129 | # /media/{comment-id}/comment_like: 130 | # /media/{comment-id}/comment_unlike: 131 | # /media/{comment-id}/comment_likers: 132 | # /media/{media-id}/{only_me}: 133 | # /media/{media-id}/info: 134 | # /media/{media-id}/infos: 135 | # /media/{media-id}/like: 136 | # /media/{media-id}/unlike: 137 | # /media/{media-id}/likers: 138 | # /media/{media-id}/likers_chrono: 139 | # /media/{media-id}/save: 140 | # /media/{media-id}/unsave: 141 | # /media/{media-id}/permalink: 142 | # /media/{media-id}/edit_media: 143 | # /media/{media-id}/delete: 144 | # /media/{media-id}/enable_comments: 145 | # /media/{media-id}/disable_comments: 146 | # /media/{media-id}/comment: 147 | # /media/{media-id}/comment/bulk_delete: 148 | # /media/{media-id}/comment/{comment-id}/child_comments: 149 | # /media/{media-id}/comments: 150 | # /media/{media-id}/comments/{comment-id}/child_comments: 151 | # /media/{media-id}/comments/{comment-id}/inline_child_comments: 152 | 153 | # COLLECTIONS endpoints 154 | 155 | # /feed/collection/{collection-id}: 156 | # /collections/{collection-id}/edit: 157 | # /collections/{collection-id}/delete: 158 | 159 | # DISCOVER endpoints 160 | 161 | # /discover: 162 | # /discover/channels_home: 163 | # /discover/chaining: 164 | # /discover/top_live: 165 | # /discover/top_live_status: 166 | 167 | # FEED endpoints 168 | 169 | # /feed: 170 | # /feed/liked: 171 | # /feed/saved: 172 | # /feed/only_me_feed: 173 | # /feed/timeline: 174 | # /feed/popular: 175 | # /feed/reels_tray: 176 | # /feed/reels_media: 177 | # /feed/tag/{tag}: 178 | # /feed/location/{location-id}: 179 | # /feed/user/{user-id}: 180 | # /feed/user/{user-name}/username: 181 | # /feed/user/{user-id}/reel_media: 182 | # /feed/user/{user-id}/story: 183 | 184 | # FRIENDSHIPS endpoints 185 | 186 | # /friendships: 187 | # /friendships/autocomplete_user_list: 188 | # /friendships/{user-id}/following: 189 | # /friendships/pending: 190 | # /friendships/show/{user-id}: 191 | # /friendships/show_many: 192 | # /friendships/create/{user-id}: 193 | # /friendships/destroy/{user-id}: 194 | # /friendships/block/{user-id}: 195 | # /friendships/unblock/{user-id}: 196 | # /friendships/block_friend_reel/{user-id}: 197 | # /friendships/unblock_friend_reel/{user-id}: 198 | # /friendships/set_reel_block_status: 199 | # /friendships/blocked_reels: 200 | # /friendships/favorite/{user-id}: 201 | # /friendships/unfavorite/{user-id}: 202 | # /friendships/ignore/{user-id}: 203 | # /friendships/remove_follower/{user-id}: 204 | 205 | # HIGHLIGHTS endpoints 206 | 207 | # /highlights: 208 | # /highlights/create_reel: 209 | # /highlights/{user-id}/highlights_tray: 210 | # /highlights/{highlight-id}/edit_reel: 211 | # /highlights/{highlight-id}/delete_reel: 212 | 213 | # IGTV endpoints 214 | 215 | # /igtv/channel: 216 | # /igtv/search: 217 | # /igtv/tv_guide: 218 | 219 | # LIVE endpoints 220 | 221 | # /live/get_suggested_broadcasts: 222 | # /live/{broadcast-id}/info: 223 | # /live/{broadcast-id}/like: 224 | # /live/{broadcast-id}/comment: 225 | # /live/{broadcast-id}/get_comment: 226 | # /live/{broadcast-id}/get_like_count: 227 | # /live/{broadcast-id}/get_post_live_likes: 228 | # /live/{broadcast-id}/get_post_live_comments: 229 | # /live/{broadcast-id}/heartbeat_and_get_viewer_count: 230 | 231 | # MISCS endpoints 232 | 233 | # /qe/expose: 234 | # /oembed: 235 | # /news: 236 | # /news/inbox: 237 | # /language/bulk_translate: 238 | # /fbsearch/topsearch: 239 | # /direct_v2/ranked_recipients: 240 | # /direct_share/recent_recipients: 241 | 242 | # LOCATIONS endpoints 243 | 244 | # /locations/{location-id}/info: 245 | # /locations/{location-id}/related: 246 | # /locations/{location-id}/sections: 247 | 248 | # TAGS endpoints 249 | 250 | # /tags/sarch: 251 | # /tags/suggested: 252 | # /tags/follow/{hashtag}: 253 | # /tags/unfollow/{hashtag}: 254 | # /tags/{tag}/info: 255 | # /tags/{tag}/related: 256 | # /tags/{tag}/sections: 257 | 258 | # USERTAGS endpoints 259 | 260 | # /usertags/{user-id}/feed: 261 | # /usertags/{media-id}/remove: -------------------------------------------------------------------------------- /api/endpointsraw.txt: -------------------------------------------------------------------------------- 1 | accounts/two_factor_login/ 2 | accounts/send_two_factor_login_sms/ 3 | accounts/change_profile_picture/ 4 | accounts/check_phone_number/ 5 | accounts/contact_point_prefill/ 6 | accounts/create/ 7 | accounts/create_validated/ 8 | accounts/disable_sms_two_factor/ 9 | accounts/edit_profile/ 10 | accounts/enable_sms_two_factor/ 11 | accounts/get_comment_filter/ 12 | accounts/login/ 13 | accounts/logout/ 14 | accounts/read_msisdn_header/ 15 | accounts/regen_backup_codes/ 16 | accounts/remove_profile_picture/ 17 | accounts/current_user/?edit=true 18 | accounts/account_security_info/ 19 | accounts/send_confirm_email/ 20 | accounts/send_recovery_flow_email/ 21 | accounts/send_signup_sms_code/ 22 | accounts/send_sms_code/ 23 | accounts/send_two_factor_enable_sms/ 24 | accounts/set_biography/ 25 | accounts/set_phone_and_name/ 26 | accounts/set_presence_disabled/ 27 | accounts/update_business_info/ 28 | accounts/username_suggestions/ 29 | accounts/validate_signup_sms_code/ 30 | accounts/verify_sms_code/ 31 | accounts/change_password/ 32 | accounts/current_user?edit=true 33 | accounts/set_private/ 34 | accounts/set_public/ 35 | accounts/convert_to_personal/ 36 | accounts/create_business_info/ 37 | accounts/get_presence_disabled/ 38 | accounts/get_blocked_commenters/ 39 | accounts/set_blocked_commenters/ 40 | 41 | business/instant_experience/get_ix_partners_bundle/?signed_body={0}&ig_sig_key_version={1} 42 | business/account/set_business_category/ 43 | business/instant_experience/ix_validate_url/ 44 | business/branded_content/get_whitelist_settings/ 45 | business/branded_content/update_whitelist_settings/ 46 | business_conversion/get_business_convert_social_context/ 47 | 48 | collection_create 49 | collections/create/ 50 | collections/{0}/delete/ 51 | collections/{0}/edit/ 52 | feed_saved_add_to_collection 53 | collections/list/ 54 | 55 | consent/new_user_flow/ 56 | consent/new_user_flow_begins/ 57 | 58 | 59 | discover/ayml/ 60 | discover/chaining/?target_id={0} 61 | discover/explore/ 62 | discover/topical_explore/ 63 | discover/fetch_suggestion_details/?target_id={0}&chained_ids={1} 64 | discover/top_live/ 65 | discover/top_live_status/ 66 | 67 | fbsearch/clear_search_history 68 | fbsearch/get_hidden_search_entities/ 69 | 70 | fbsearch/hide_search_entities 71 | 72 | fbsearch/places/ 73 | 74 | fbsearch/profile_link_search/?q={0}&count={1} 75 | fbsearch/recent_searches/ 76 | fbsearch/suggested_searches/?type={0} 77 | fbsearch/topsearch/ 78 | fbsearch/topsearch_flat/ 79 | fbsearch/topsearch_flat/?rank_token={0}&timezone_offset={1}&query={2}&context={3} 80 | 81 | fb/fb_entrypoint_info/ 82 | fb/facebook_signup/ 83 | fb/get_invite_suggestions/ 84 | 85 | feed/only_me_feed/ 86 | 87 | feed/popular/?people_teaser_supported=1&rank_token={0}&ranked_content=true 88 | 89 | feed/promotable_media/ 90 | feed/reels_media/ 91 | feed/saved/ 92 | feed/collection/{0}/ 93 | feed/reels_tray/ 94 | feed/tag/{0} 95 | feed/user/{0}/reel_media/ 96 | fsertags/{0}/feed/ 97 | feed/liked/ 98 | feed/timeline 99 | feed/user/{0}/reel_media/ 100 | feed/user/ 101 | 102 | friendships/approve/{0}/ 103 | friendships/autocomplete_user_list/ 104 | friendships/block/{0}/ 105 | friendships/create/{0}/ 106 | friendships/ignore/{0}/ 107 | friendships/pending/?rank_mutual=0&rank_token={0} 108 | friendships/remove_follower/{0}/ 109 | friendships/set_reel_block_status/ 110 | friendships/show_many/ 111 | friendships/unblock/{0}/ 112 | friendships/favorite/{0}/ 113 | friendships/unfavorite/{0}/ 114 | friendships/favorite_for_stories/{0}/ 115 | friendships/unfavorite_for_stories/{0}/ 116 | friendships/destroy/{0}/ 117 | friendships/{0}/followers/?rank_token={1} 118 | friendships/{0}/followers/?rank_token={1}&rank_mutual={2} 119 | friendships/{0}/following/?rank_token={1} 120 | friendships/show/ 121 | friendships/mark_user_overage/{0}/feed/ 122 | friendships/mute_posts_or_story_from_follow/ 123 | friendships/unmute_posts_or_story_from_follow/ 124 | friendships/block_friend_reel/{0}/ 125 | friendships/unblock_friend_reel/{0}/ 126 | friendships/mute_friend_reel/{0}/ 127 | friendships/unmute_friend_reel/{0}/ 128 | friendships/blocked_reels/ 129 | friendships/besties/ 130 | friendships/bestie_suggestions/ 131 | friendships/set_besties/ 132 | 133 | ads/graphql/ 134 | locale={0}&vc_policy=insights_policy&surface={1} 135 | insights/account_organic_insights/?show_promotions_in_landing_page=true&first={0} 136 | insights/media_organic_insights/{0}?{1}={2} 137 | 138 | highlights/create_reel/ 139 | highlights/{0}/delete_reel/ 140 | highlights/{0}/edit_reel/ 141 | highlights/{0}/highlights_tray/ 142 | 143 | igtv/channel/ 144 | igtv/search/?query={0} 145 | igtv/suggested_searches/ 146 | igtv/tv_guide/ 147 | media/configure_to_igtv/ 148 | 149 | language/translate/?id={0}&type=3 150 | language/bulk_translate/?comment_ids={0} 151 | 152 | live/{0}/add_to_post_live/ 153 | live/{0}/comment/ 154 | live/create/ 155 | live/{0}/delete_post_live/ 156 | live/{0}/end_broadcast/ 157 | live/{0}/get_comment/ 158 | live/{0}/get_comment/?last_comment_ts={1} 159 | live/{0}/get_final_viewer_list/ 160 | live/{0}/get_join_requests/ 161 | live/{0}/get_like_count/ 162 | live/get_live_presence/?presence_type=30min 163 | live/{0}/get_post_live_comments/?starting_offset={1}&encoding_tag={2} 164 | live/{0}/get_post_live_viewers_list/ 165 | live/get_suggested_broadcasts/ 166 | live/{0}/get_viewer_list/ 167 | live/{0}/heartbeat_and_get_viewer_count/ 168 | live/{0}/info/ 169 | live/{0}/like/ 170 | live/{0}/mute_comment/ 171 | live/{0}/pin_comment/ 172 | live/{0}/get_post_live_likes/?starting_offset={1}&encoding_tag={2} 173 | live/{0}/start/ 174 | live/{0}/unmute_comment/ 175 | live/{0}/unpin_comment/ 176 | 177 | media/{0}/enable_comments/ 178 | media/{0}/comment/{1}/delete/ 179 | media/{0}/delete/?media_type={1} 180 | media/{0}/comment/bulk_delete/ 181 | media/{0}/disable_comments/ 182 | media/{0}/edit_media/ 183 | media/{0}/info/ 184 | media/{0}/permalink/ 185 | media/{0}/comment_like/ 186 | media/{0}/like/ 187 | media/?max_id= 188 | media/ 189 | media/configure_sidecar/ 190 | media/{0}/comment_likers/ 191 | media/{0}/comments/?can_support_threading=true 192 | media/configure/ 193 | media/configure/?video=1 194 | media/upload_finish/?video=1 195 | media/infos/?_uuid={0}&_csrftoken={1}&media_ids={2}&ranked_content=true&include_inactive_reel=true 196 | media/configure_to_nametag/ 197 | media/{0}/comments/{1}/inline_child_comments/ 198 | media/{0}/likers/ 199 | media/{0}/flag_media/ 200 | media/{0}/comment/{1}/flag/ 201 | media/{0}/save/ 202 | media/{0}/unsave/ 203 | 204 | media/validate_reel_url/ 205 | media/{0}/comment/ 206 | media/seen/ 207 | media/configure_to_reel/ 208 | media/configure_to_story/?video=1 209 | media/configure_to_story/ 210 | media/mas_opt_in_info/ 211 | media/{0}/comment_unlike/ 212 | media/{0}/unlike/ 213 | media/{0}/list_reel_media_viewer/ 214 | media/blocked/ 215 | media/{0}/only_me/ 216 | media/{0}/undo_only_me/ 217 | media/{0}/{1}/story_poll_voters/ 218 | media/{0}/{1}/story_poll_vote/ 219 | media/{0}/{1}/story_slider_vote/ 220 | media/{0}/{1}/story_question_response/ 221 | media/story_countdowns/ 222 | media/{0}/follow_story_countdown/ 223 | media/{0}/unfollow_story_countdown/ 224 | 225 | news/ 226 | news/inbox/ 227 | 228 | news/log/ 229 | 230 | notifications/badge/ 231 | uush/register/ 232 | 233 | feed/user/{0}/shoppable_media/ 234 | 235 | ecommerce/products/{0}/?media_id={1}&device_width={2} 236 | 237 | tags/{0}/info/ 238 | tags/search/?q={0}&count={1} 239 | tags/follow/{0}/ 240 | tags/{0}/ranked_sections/ 241 | tags/{0}/recent_sections/ 242 | tags/{0}/sections/ 243 | tags/{0}/related/ 244 | tags/{0}/story/ 245 | tags/suggested/ 246 | tags/unfollow/{0}/ 247 | 248 | users/lookup_phone/ 249 | users/{0}/info/ 250 | users/{0}/usernameinfo/ 251 | users/search 252 | users/check_email/ 253 | users/check_username/ 254 | users/lookup/ 255 | users/nametag_config/ 256 | users/reel_settings/ 257 | users/{0}/flag_user/ 258 | users/search/?timezone_offset={0}&q={1}&count={2} 259 | users/set_reel_settings/ 260 | users/{0}/following_tags_info/ 261 | users/{0}/full_detail_info/ 262 | users/nametag_lookup/ 263 | users/blocked_list/ 264 | users/{0}/account_details/ 265 | 266 | rupload_igphoto/{0}_0_{1} 267 | upload/photo/ 268 | rupload_igvideo/{0}_0_{1} 269 | upload/video/ 270 | address_book/link/?include=extra_display_name,thumbnails 271 | 272 | archive/reel/day_shells/?include_cover=0 273 | dyi/request_download_data/ 274 | dyi/check_data_state/ 275 | dynamic_onboarding/get_steps/ 276 | oembed/?url={0} 277 | megaphone/log/ 278 | 279 | qe/expose/ 280 | 281 | challenge/ 282 | 283 | accounts 284 | access_tool 285 | current_follow_requests 286 | former_emails 287 | former_phones 288 | former_usernames 289 | former_full_names 290 | former_bio_texts 291 | former_links_in_bio 292 | 293 | direct_share/recent_recipients/ 294 | direct_share/inbox/ 295 | 296 | direct_v2/threads/broadcast/configure_video/ 297 | direct_v2/threads/broadcast/link/ 298 | direct_v2/threads/broadcast/like/ 299 | direct_v2/threads/broadcast/location/ 300 | direct_v2/threads/broadcast/media_share/?media_type={0} 301 | direct_v2/threads/broadcast/profile/ 302 | direct_v2/threads/broadcast/reaction/ 303 | direct_v2/threads/broadcast/reel_share/ 304 | direct_v2/threads/broadcast/upload_photo/ 305 | direct_v2/threads/broadcast/hashtag/ 306 | direct_v2/threads/broadcast/live_viewer_invite/ 307 | 308 | direct_v2/create_group_thread/ 309 | 310 | direct_v2/get_presence/ 311 | direct_v2/threads/{0}/label/ 312 | direct_v2/threads/{0}/hide/ 313 | direct_v2/threads/{0}/add_user/ 314 | 315 | direct_v2/visual_threads/{0}/item_seen/ 316 | direct_v2/threads/{0}/items/{1}/seen/ 317 | direct_v2/threads/{0}/leave/ 318 | direct_v2/threads/{0}/mute/ 319 | direct_v2/threads/{0}/unmute/ 320 | direct_v2/threads/{0}/update_title/ 321 | direct_v2/threads/{0}/unlabel/ 322 | direct_v2/inbox/ 323 | direct_v2/pending_inbox/ 324 | direct_v2/threads/broadcast/profile/ 325 | direct_v2/threads/broadcast/text/ 326 | direct_v2/threads/{0} 327 | direct_v2/threads/{0}/approve/ 328 | direct_v2/threads/approve_multiple/ 329 | direct_v2/threads/{0}/decline/ 330 | direct_v2/threads/decline_multiple/ 331 | direct_v2/threads/decline_all/ 332 | direct_v2/threads/get_by_participants/?recipient_users=[{0}] 333 | direct_v2/ranked_recipients/?mode=raven&show_threads=true&query={0}&use_unified_inbox=true 334 | direct_v2/ranked_recipients 335 | direct_v2/threads/broadcast/story_share/?media_type={0} 336 | direct_v2/threads/{0}/items/{1}/delete/ 337 | 338 | ### API 2 Endpoints ### 339 | media/seen/?reel=1&live_vod=0 340 | 341 | -------------------------------------------------------------------------------- /api/headers.yaml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Headers # 3 | ################################################################################ 4 | # Documentation link -------------------------------------------------------------------------------- /api/instagram.yaml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.1 2 | ################################################################################ 3 | # API Information # 4 | ################################################################################ 5 | info: 6 | title: Instagram API 7 | description: The Instagram Private API in OpenAPI specs.v3.0 8 | version: 0.0.1 9 | ################################################################################ 10 | # Host, Base Path, Schemes and Content Types # 11 | ################################################################################ 12 | servers: 13 | - url: https://i.instagram.com/api/v1 14 | description: The private API of Instagram 15 | ################################################################################ 16 | # Paths (Endpoints) # 17 | ################################################################################ 18 | paths: 19 | $ref: './endpoints.yaml' 20 | ################################################################################ 21 | # Definitions # 22 | ################################################################################ 23 | components: 24 | securitySchemes: 25 | $ref: './auth.yaml' 26 | schemas: 27 | $ref: './schemas.yaml#/schemas' 28 | # headers: 29 | # $ref: './headers.yaml' 30 | parameters: 31 | $ref: './parameters.yaml' 32 | requestBodies: 33 | $ref: './body.yaml' -------------------------------------------------------------------------------- /api/parameters.yaml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Parameters # 3 | ################################################################################ 4 | # Documentation link 5 | # https://swagger.io/docs/specification/describing-parameters/ 6 | 7 | #----------------- 8 | # Path params 9 | #----------------- 10 | user-id: 11 | in: path 12 | name: user_id 13 | schema: 14 | type: integer 15 | required: true 16 | description: > 17 | the user id (or the logged_in_user.pk in login() response) 18 | 19 | #----------------- 20 | # Query params 21 | #----------------- 22 | username: 23 | in: query 24 | name: username 25 | schema: 26 | type: string 27 | required: true 28 | description: > 29 | the username (or nickname) 30 | #----------------- 31 | password: 32 | in: query 33 | name: password 34 | schema: 35 | type: string 36 | required: true 37 | description: > 38 | the password to use for authentication 39 | 40 | #----------------- 41 | # Header params 42 | #----------------- 43 | ua: 44 | in: header 45 | name: User-Agent 46 | schema: 47 | type: string 48 | required: true 49 | description: > 50 | the User-Agent used by the Instagram App (be carefull in generation of a new one) 51 | accept-language: 52 | in: header 53 | name: Accept-Language 54 | schema: 55 | type: string 56 | required: true 57 | description: > 58 | the User-Agent used by the Instagram App (be carefull in generation of a new one) 59 | ig-connection-speed: 60 | in: header 61 | name: X-IG-Connection-Speed 62 | schema: 63 | type: string 64 | # format: uuid 65 | required: true 66 | ig-bandwidth-speed-kbps: 67 | in: header 68 | name: X-IG-Bandwidth-Speed-KBPS 69 | schema: 70 | type: string 71 | # format: uuid 72 | required: true 73 | ig-bandwidth-total-bytes: 74 | in: header 75 | name: X-IG-Bandwidth-TotalBytes-B 76 | schema: 77 | type: string 78 | # format: uuid 79 | required: true 80 | ig-bandwidth-total-time: 81 | in: header 82 | name: X-IG-Bandwidth-TotalTime-MS 83 | schema: 84 | type: string 85 | # format: uuid 86 | required: true 87 | ig-connection-type: 88 | in: header 89 | name: X-IG-Connection-Type 90 | schema: 91 | type: string 92 | # format: uuid 93 | required: true 94 | ig-capabilities: 95 | in: header 96 | name: X-IG-Capabilities 97 | schema: 98 | type: string 99 | # format: uuid 100 | required: true 101 | ig-app-id: 102 | in: header 103 | name: X-IG-App-ID 104 | schema: 105 | type: string 106 | # format: uuid 107 | required: true 108 | 109 | #----------------- 110 | # Cookie params 111 | #----------------- 112 | ds_user: 113 | in: cookie 114 | name: ds_user 115 | schema: 116 | type: string 117 | # format: uuid 118 | required: true 119 | ds_user_id: 120 | in: cookie 121 | name: ds_user_id 122 | schema: 123 | type: string 124 | # format: uuid 125 | required: true 126 | shbts: 127 | in: cookie 128 | name: shbts 129 | schema: 130 | type: string 131 | # format: uuid 132 | required: true 133 | mid: 134 | in: cookie 135 | name: mid 136 | schema: 137 | type: string 138 | # format: uuid 139 | required: true 140 | sessionid: 141 | in: cookie 142 | name: sessionid 143 | schema: 144 | type: string 145 | # format: uuid 146 | required: true 147 | csrftoken: 148 | in: cookie 149 | name: csrftoken 150 | schema: 151 | type: string 152 | # format: uuid 153 | required: true 154 | shbid: 155 | in: cookie 156 | name: shbid 157 | schema: 158 | type: string 159 | # format: uuid 160 | required: true 161 | rur: 162 | in: cookie 163 | name: rur 164 | schema: 165 | type: string 166 | # format: uuid 167 | required: true -------------------------------------------------------------------------------- /api/schemas.yaml: -------------------------------------------------------------------------------- 1 | schemas: 2 | User: 3 | type: object 4 | properties: 5 | username: 6 | type: string 7 | Error: 8 | type: object 9 | properties: 10 | message: 11 | type: string 12 | status: 13 | type: string 14 | error_type: 15 | type: string 16 | JsonObject: 17 | type: object 18 | properties: 19 | message: 20 | type: string 21 | status: 22 | type: string 23 | error_type: 24 | type: string 25 | AuthBody: 26 | type: object 27 | properties: 28 | ig_sig_key_version: 29 | type: integer 30 | signed_body: 31 | type: string 32 | -------------------------------------------------------------------------------- /configs/javascript.yaml: -------------------------------------------------------------------------------- 1 | 2 | # Sort method arguments to place required parameters before optional parameters. (Default: true) 3 | # sortParamsByRequiredFlag: 4 | 5 | # Whether to ensure parameter names are unique in an operation (rename parameters that are not). (Default: true) 6 | # ensureUniqueParams: 7 | 8 | # boolean, toggles whether unicode identifiers are allowed in names or not, default is false (Default: false) 9 | # allowUnicodeIdentifiers: 10 | 11 | # Add form or body parameters to the beginning of the parameter list. (Default: false) 12 | # prependFormOrBodyParameters: 13 | 14 | # source folder for generated code (Default: src) 15 | # sourceFolder: 16 | 17 | # root package for generated code 18 | # invokerPackage: 19 | 20 | # package for generated api classes 21 | # apiPackage: 22 | 23 | # package for generated models 24 | # modelPackage: 25 | 26 | # name of the project (Default: generated from info.title or "openapi-js-client") 27 | # projectName: 28 | 29 | # module name for AMD, Node or globals (Default: generated from ) 30 | # moduleName: 31 | 32 | # description of the project (Default: using info.description or "Client library of ") 33 | # projectDescription: 34 | 35 | # version of the project (Default: using info.version or "1.0.0") 36 | # projectVersion: 37 | 38 | # name of the license the project uses (Default: using info.license.name) 39 | # licenseName: 40 | 41 | # use Promises as return values from the client API, instead of superagent callbacks (Default: false) 42 | # usePromises: 43 | 44 | # generate getters and setters for model properties (Default: false) 45 | # emitModelMethods: 46 | 47 | # generate JSDoc comments (Default: true) 48 | # emitJSDoc: 49 | 50 | # use JavaScript prototype chains & delegation for inheritance (Default: true) 51 | # useInheritance: 52 | 53 | # Hides the generation timestamp when files are generated. (Default: true) 54 | # hideGenerationTimestamp: 55 | 56 | # use JavaScript ES6 (ECMAScript 6) (beta). Default is ES6. (Default: true) 57 | # useES6: 58 | 59 | # Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name (Default: camelCase) 60 | # modelPropertyNaming: 61 | 62 | -------------------------------------------------------------------------------- /configs/python.yaml: -------------------------------------------------------------------------------- 1 | # CONFIG OPTIONS 2 | 3 | # python package name (convention: snake_case). (Default: openapi_client) 4 | packageName: private_instagram_sdk 5 | 6 | # python project name in setup.py (e.g. petstore-api). 7 | projectName: private-instagram-sdk 8 | 9 | # python package version. (Default: 1.0.0) 10 | packageVersion: 1.0.0 11 | 12 | # python package URL. 13 | packageUrl: https://github.com/instagrambot/instagram-api-toolkit 14 | 15 | # Sort method arguments to place required parameters before optional parameters. (Default: true) 16 | # sortParamsByRequiredFlag: 17 | 18 | # Hides the generation timestamp when files are generated. (Default: true) 19 | # hideGenerationTimestamp: 20 | 21 | # Specifies that only a library source code is to be generated. (Default: false) 22 | # generateSourceCodeOnly: 23 | 24 | # library template (sub-template) to use: asyncio, tornado, urllib3 (Default: urllib3) 25 | # library: 26 | -------------------------------------------------------------------------------- /generators/python.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Python", 3 | "type": "client", 4 | "defaults": { 5 | "projectName": "private_instagram_sdk", 6 | "packageName": "private_instagram_sdk", 7 | "package": "private_instagram_sdk", 8 | "packageVersion": "1.0.0", 9 | "packageUrl": "https://github.com/instagrambot/instagram-api-toolkit", 10 | "baseNamespace": "private_instagram_sdk", 11 | "generatorPackage": "private_instagram_sdk", 12 | "invokerPackage": "private_instagram_sdk", 13 | "importPath": "private_instagram_sdk", 14 | "apiPackage": "private_instagram_sdk.api", 15 | "pythonPackageName":"private_instagram_sdk", 16 | "modelPackage": "private_instagram_sdk.models", 17 | "clientPackage": "private_instagram_sdk.api_client", 18 | "modelNaming": "PascalCase", 19 | "modelPropertyNaming": "snake_case", 20 | "imports": [] 21 | }, 22 | "directories": [ 23 | "private_instagram_sdk", 24 | "private_instagram_sdk/models", 25 | "private_instagram_sdk/api", 26 | "test", 27 | "docs" 28 | ], 29 | "partials": { 30 | "partial_header": "partial_header.mustache" 31 | }, 32 | "transformations": [ 33 | { "input": "tox.mustache", "output": "tox.ini" }, 34 | { "input": "setup.mustache", "output": "setup.py" }, 35 | { "input": "README.mustache", "output": "README.md" }, 36 | { "input": "travis.mustache", "output": ".travis.yml" }, 37 | { "input": "gitignore.mustache", "output": ".gitignore" }, 38 | { "input": "api_test.mustache", "output": "api_test.py" }, 39 | { "input": "git_push.sh.mustache", "output": "git_push.sh" }, 40 | { "input": "requirements.mustache", "output": "requirements.txt" }, 41 | { "input": "test-requirements.mustache", "output": "test-requirements.txt" }, 42 | { "input": "__init__test.mustache", "output": "test/__init__.py" }, 43 | { "input": "exceptions.mustache", "output": "private_instagram_sdk/exceptions.py" }, 44 | { "input": "rest.mustache", "output": "private_instagram_sdk/rest.py" }, 45 | { "input": "configuration.mustache", "output": "private_instagram_sdk/configuration.py" }, 46 | { "input": "api_client.mustache", "output": "private_instagram_sdk/api_client.py" }, 47 | { "input": "__init__api.mustache", "output": "private_instagram_sdk/api/__init__.py" }, 48 | { "input": "__init__model.mustache", "output": "private_instagram_sdk/models/__init__.py" }, 49 | { "input": "__init__package.mustache", "output": "private_instagram_sdk/__init__.py" } 50 | ], 51 | "perApi":[ 52 | { "input": "api_doc.mustache", "output": "docs/{{name}}Api.md" }, 53 | { "input": "api.mustache", "output": "private_instagram_sdk/api/{{name}}.py" } 54 | ], 55 | "perModel": [ 56 | { "input": "model.mustache", "output": "private_instagram_sdk/models/{{#models}}{{#model}}{{name}}{{/model}}{{/models}}.py" }, 57 | { "input": "model_test.mustache", "output": "test/test_{{#models}}{{#model}}{{name}}{{/model}}{{/models}}.py" }, 58 | { "input": "model_doc.mustache", "output": "docs/{{#models}}{{#model}}{{name}}{{/model}}{{/models}}.md" } 59 | ] 60 | } 61 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "instagram-api-toolkit", 3 | "version": "0.0.1", 4 | "description": "toolkit to create multiple SDKs of Instagram Private API for whatever languages and frameworks", 5 | "main": "toolkit.js", 6 | "repository": "https://github.com/instagrambot/instagram-api-toolkit.git", 7 | "author": "Benedetto Abbenanti ", 8 | "license": "MIT", 9 | "private": true, 10 | "scripts": { 11 | "generate": "yarn build-schema && ./tools/auto_generate_sdks.sh", 12 | "toolkit": "node toolkit.build.js", 13 | "build-toolkit": "babel toolkit.js -o toolkit.build.js", 14 | "viewer": "yarn build-schema && openapi-viewer instagram-api.bundle.json", 15 | "install-python-sdk": "cd ./sdks/python && python setup.py install", 16 | "test-python": "yarn install-python-sdk && python ./test/python-sdk.py", 17 | "validate": "yarn build-schema && swagger-cli validate instagram-api.bundle.json", 18 | "build-schema": "swagger-cli bundle -r -o instagram-api.bundle.json ./api/instagram.yaml" 19 | }, 20 | "devDependencies": { 21 | "@babel/cli": "^7.4.4", 22 | "@babel/core": "^7.4.4", 23 | "@babel/preset-env": "^7.4.4", 24 | "swagger-cli": "^2.2.1" 25 | }, 26 | "dependencies": { 27 | "@babel/polyfill": "^7.4.4", 28 | "@openapitools/openapi-generator-cli": "^0.0.9-4.0.0-beta3", 29 | "chalk": "^2.4.2", 30 | "core-js": "3", 31 | "enquirer": "^2.3.0", 32 | "openapi-codegen": "^1.5.5", 33 | "openapi-viewer": "^1.0.1", 34 | "shelljs": "^0.8.3" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /private-instagram-api-toolkit-sdk-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b3nab/instagram-api-toolkit/b68a52e1a3cfa4f1b67850d13f502e82b5743304/private-instagram-api-toolkit-sdk-banner.png -------------------------------------------------------------------------------- /sdks/README.md: -------------------------------------------------------------------------------- 1 | # SDKs for languages and frameworks 2 | 3 | Here there is a list of all SDKs available to download and use: 4 | 5 | ## Language SDKs 6 | 7 | | language | package-name | 8 | | -------- | ------------ | 9 | | - | - | 10 | 11 | ## Framework SDKs 12 | 13 | | framework | package-name | 14 | | -------- | ------------ | 15 | | - | - | -------------------------------------------------------------------------------- /sdks/python/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | venv/ 48 | .python-version 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | 57 | # Sphinx documentation 58 | docs/_build/ 59 | 60 | # PyBuilder 61 | target/ 62 | 63 | #Ipython Notebook 64 | .ipynb_checkpoints 65 | -------------------------------------------------------------------------------- /sdks/python/.travis.yml: -------------------------------------------------------------------------------- 1 | # ref: https://docs.travis-ci.com/user/languages/python 2 | language: python 3 | python: 4 | - "2.7" 5 | - "3.2" 6 | - "3.3" 7 | - "3.4" 8 | - "3.5" 9 | #- "3.5-dev" # 3.5 development branch 10 | #- "nightly" # points to the latest development branch e.g. 3.6-dev 11 | # command to install dependencies 12 | install: "pip install -r requirements.txt" 13 | # command to run tests 14 | script: nosetests 15 | -------------------------------------------------------------------------------- /sdks/python/LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /sdks/python/README.md: -------------------------------------------------------------------------------- 1 | # private_instagram_sdk 2 | The Instagram Private API in OpenAPI specs.v3.0 3 | 4 | This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: 5 | 6 | - API version: 0.0.1 7 | - Package version: 1.0.0 8 | - Build date: Mon May 13 2019 19:03:18 GMT+0200 (GMT+02:00) 9 | - Build package: python 10 | 11 | ## Requirements. 12 | 13 | Python 2.7 and 3.4+ 14 | 15 | ## Installation & Usage 16 | ### pip install 17 | 18 | If the python package is hosted on Github, you can install directly from Github 19 | 20 | ```sh 21 | pip install git+https://github.com/Mermade/openapi-codegen.git 22 | ``` 23 | (you may need to run `pip` with root permission: `sudo pip install git+https://github.com/Mermade/openapi-codegen.git`) 24 | 25 | Then import the package: 26 | ```python 27 | import private_instagram_sdk 28 | ``` 29 | 30 | ### Setuptools 31 | 32 | Install via [Setuptools](http://pypi.python.org/pypi/setuptools). 33 | 34 | ```sh 35 | python setup.py install --user 36 | ``` 37 | (or `sudo python setup.py install` to install the package for all users) 38 | 39 | Then import the package: 40 | ```python 41 | import private_instagram_sdk 42 | ``` 43 | 44 | ## Getting Started 45 | 46 | Please follow the [installation procedure](#installation--usage) and then run the following: 47 | 48 | -------------------------------------------------------------------------------- /sdks/python/api_test.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | from __future__ import absolute_import 13 | 14 | import unittest 15 | 16 | import private_instagram_sdk 17 | from private_instagram_sdk.api.default import instagram_api # noqa: E501 18 | from private_instagram_sdk.rest import ApiException 19 | 20 | 21 | class 22 | if __name__ == '__main__': 23 | unittest.main() 24 | -------------------------------------------------------------------------------- /sdks/python/docs/AuthApi.md: -------------------------------------------------------------------------------- 1 | # private_instagram_sdk.AuthApi 2 | 3 | All URIs are relative to */api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**login**](AuthApi.md#login) | **POST** /accounts/login/ | Login user to Instagram 8 | 9 | # **login** 10 | > object login(body) 11 | 12 | Login user to Instagram 13 | 14 | Login to Instagram with username/password 15 | 16 | ### Example 17 | 18 | * Api Key Authentication (cookieAuth): 19 | ### Parameters 20 | 21 | Name | Type | Description | Notes 22 | ------------- | ------------- | ------------- | ------------- 23 | **body** | [**object**](object.md)| Optional description in *Markdown* | 24 | 25 | ### Return type 26 | 27 | **object** 28 | 29 | ### Authorization 30 | 31 | [cookieAuth](../README.md#cookieAuth) 32 | 33 | ### HTTP request headers 34 | 35 | - **Content-Type**: application/x-www-form-urlencoded 36 | - **Accept**: application/json, application/json, application/json 37 | 38 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 39 | 40 | -------------------------------------------------------------------------------- /sdks/python/docs/AuthBody.md: -------------------------------------------------------------------------------- 1 | # AuthBody 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **ig_sig_key_version** | **** | | [optional] 7 | **signed_body** | **** | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sdks/python/docs/Error.md: -------------------------------------------------------------------------------- 1 | # Error 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **message** | **** | | [optional] 7 | **status** | **** | | [optional] 8 | **error_type** | **** | | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sdks/python/docs/JsonObject.md: -------------------------------------------------------------------------------- 1 | # JsonObject 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **message** | **** | | [optional] 7 | **status** | **** | | [optional] 8 | **error_type** | **** | | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sdks/python/docs/User.md: -------------------------------------------------------------------------------- 1 | # User 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **username** | **** | | [optional] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /sdks/python/docs/UserApi.md: -------------------------------------------------------------------------------- 1 | # private_instagram_sdk.UserApi 2 | 3 | All URIs are relative to */api/v1* 4 | 5 | Method | HTTP request | Description 6 | ------------- | ------------- | ------------- 7 | [**getUser**](UserApi.md#getUser) | **GET** /users/{user_id}/info/ | User Profile 8 | 9 | # **getUser** 10 | > object getUser(user_id) 11 | 12 | User Profile 13 | 14 | The User Profile endpoint returns information about the Instagram user that has authorized with the application. 15 | 16 | ### Example 17 | 18 | ### Parameters 19 | 20 | Name | Type | Description | Notes 21 | ------------- | ------------- | ------------- | ------------- 22 | **user_id** | **integer**| the user id (or the logged_in_user.pk in login() response) 23 | | 24 | 25 | ### Return type 26 | 27 | **object** 28 | 29 | ### Authorization 30 | 31 | No authorization required 32 | 33 | ### HTTP request headers 34 | 35 | - **Content-Type**: application/x-www-form-urlencoded 36 | - **Accept**: application/json, application/json 37 | 38 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 39 | 40 | -------------------------------------------------------------------------------- /sdks/python/git_push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ 3 | # 4 | # Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" 5 | 6 | git_user_id=$1 7 | git_repo_id=$2 8 | release_note=$3 9 | 10 | if [ "$git_user_id" = "" ]; then 11 | git_user_id="Mermade" 12 | echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" 13 | fi 14 | 15 | if [ "$git_repo_id" = "" ]; then 16 | git_repo_id="openapi-codegen" 17 | echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" 18 | fi 19 | 20 | if [ "$release_note" = "" ]; then 21 | release_note="Minor update" 22 | echo "[INFO] No command line input provided. Set \$release_note to $release_note" 23 | fi 24 | 25 | # Initialize the local directory as a Git repository 26 | git init 27 | 28 | # Adds the files in the local repository and stages them for commit. 29 | git add . 30 | 31 | # Commits the tracked changes and prepares them to be pushed to a remote repository. 32 | git commit -m "$release_note" 33 | 34 | # Sets the new remote 35 | git_remote=`git remote` 36 | if [ "$git_remote" = "" ]; then # git remote not defined 37 | 38 | if [ "$GIT_TOKEN" = "" ]; then 39 | echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." 40 | git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git 41 | else 42 | git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git 43 | fi 44 | 45 | fi 46 | 47 | git pull origin master 48 | 49 | # Pushes (Forces) the changes in the local repository up to the remote repository 50 | echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" 51 | git push origin master 2>&1 | grep -v 'To https' 52 | 53 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | 5 | """ 6 | Instagram API 7 | 8 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 9 | 10 | OpenAPI spec version: 0.0.1 11 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 12 | """ 13 | 14 | from __future__ import absolute_import 15 | 16 | __version__ = "1.0.0" 17 | 18 | # import apis into sdk package 19 | from private_instagram_sdk.api.Auth import AuthApi 20 | from private_instagram_sdk.api.User import UserApi 21 | # import ApiClient 22 | from private_instagram_sdk.api_client import ApiClient 23 | from private_instagram_sdk.configuration import Configuration 24 | from private_instagram_sdk.exceptions import OpenApiException 25 | from private_instagram_sdk.exceptions import ApiTypeError 26 | from private_instagram_sdk.exceptions import ApiValueError 27 | from private_instagram_sdk.exceptions import ApiKeyError 28 | from private_instagram_sdk.exceptions import ApiException 29 | # import models into model package 30 | from private_instagram_sdk.models.User import User 31 | from private_instagram_sdk.models.Error import Error 32 | from private_instagram_sdk.models.JsonObject import JsonObject 33 | from private_instagram_sdk.models.AuthBody import AuthBody 34 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/api/Auth.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | from __future__ import absolute_import 13 | 14 | import re # noqa: F401 15 | 16 | # python 2 and python 3 compatibility library 17 | import six 18 | 19 | from private_instagram_sdk.api_client import ApiClient 20 | from private_instagram_sdk.exceptions import ( 21 | ApiTypeError, 22 | ApiValueError 23 | ) 24 | 25 | 26 | class AuthApi(object): 27 | """NOTE: This class is auto generated by OpenAPI Generator 28 | Ref: https://openapi-generator.tech 29 | 30 | Do not edit the class manually. 31 | """ 32 | 33 | def __init__(self, api_client=None): 34 | if api_client is None: 35 | api_client = ApiClient() 36 | self.api_client = api_client 37 | 38 | def login(self, body, **kwargs): # noqa: E501 39 | """ # noqa: E501 40 | 41 | Login to Instagram with username/password # noqa: E501 42 | This method makes a synchronous HTTP request by default. To make an 43 | asynchronous HTTP request, please pass async_req=True 44 | >>> thread = api.login(body, async_req=True) 45 | >>> result = thread.get() 46 | 47 | :param async_req bool 48 | :param object body: Optional description in *Markdown* (required) 49 | :return: object 50 | If the method is called asynchronously, 51 | returns the request thread. 52 | """ 53 | kwargs['_return_http_data_only'] = True 54 | if kwargs.get('async_req'): 55 | return self.login_with_http_info(body, **kwargs) # noqa: E501 56 | else: 57 | (data) = self.login_with_http_info(body, **kwargs) # noqa: E501 58 | return data 59 | 60 | def login_with_http_info(self, body, **kwargs): # noqa: E501 61 | """ # noqa: E501 62 | 63 | Login to Instagram with username/password # noqa: E501 64 | This method makes a synchronous HTTP request by default. To make an 65 | asynchronous HTTP request, please pass async_req=True 66 | >>> thread = api.login_with_http_info(body, async_req=True) 67 | >>> result = thread.get() 68 | 69 | :param async_req bool 70 | :param object body: Optional description in *Markdown* (required) 71 | :return: object 72 | If the method is called asynchronously, 73 | returns the request thread. 74 | """ 75 | 76 | local_var_params = locals() 77 | 78 | all_params = ['body'] # noqa: E501 79 | all_params.append('async_req') 80 | all_params.append('_return_http_data_only') 81 | all_params.append('_preload_content') 82 | all_params.append('_request_timeout') 83 | 84 | for key, val in six.iteritems(local_var_params['kwargs']): 85 | if key not in all_params: 86 | raise ApiTypeError( 87 | "Got an unexpected keyword argument '%s'" 88 | " to method login" % key 89 | ) 90 | local_var_params[key] = val 91 | del local_var_params['kwargs'] 92 | # verify the required parameter 'body' is set 93 | if ('body' not in local_var_params or 94 | local_var_params['body'] is None): 95 | raise ApiValueError("Missing the required parameter `body` when calling `login`") # noqa: E501 96 | 97 | collection_formats = {} 98 | 99 | path_params = {} 100 | 101 | query_params = [] 102 | 103 | header_params = {} 104 | 105 | form_params = [] 106 | local_var_files = {} 107 | 108 | body_params = None 109 | if 'body' in local_var_params: 110 | body_params = local_var_params['body'] 111 | # HTTP header `Accept` 112 | header_params['Accept'] = self.api_client.select_header_accept( 113 | ['application/json', 'application/json', 'application/json']) # noqa: E501 114 | 115 | # HTTP header `Content-Type` 116 | header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 117 | ['application/x-www-form-urlencoded']) # noqa: E501 118 | 119 | # Authentication setting 120 | auth_settings = ['cookieAuth'] # noqa: E501 121 | 122 | return self.api_client.call_api( 123 | '/accounts/login/', 'POST', 124 | path_params, 125 | query_params, 126 | header_params, 127 | body=body_params, 128 | post_params=form_params, 129 | files=local_var_files, 130 | response_type='object', # noqa: E501 131 | auth_settings=auth_settings, 132 | async_req=local_var_params.get('async_req'), 133 | _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 134 | _preload_content=local_var_params.get('_preload_content', True), 135 | _request_timeout=local_var_params.get('_request_timeout'), 136 | collection_formats=collection_formats) 137 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/api/User.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | from __future__ import absolute_import 13 | 14 | import re # noqa: F401 15 | 16 | # python 2 and python 3 compatibility library 17 | import six 18 | 19 | from private_instagram_sdk.api_client import ApiClient 20 | from private_instagram_sdk.exceptions import ( 21 | ApiTypeError, 22 | ApiValueError 23 | ) 24 | 25 | 26 | class UserApi(object): 27 | """NOTE: This class is auto generated by OpenAPI Generator 28 | Ref: https://openapi-generator.tech 29 | 30 | Do not edit the class manually. 31 | """ 32 | 33 | def __init__(self, api_client=None): 34 | if api_client is None: 35 | api_client = ApiClient() 36 | self.api_client = api_client 37 | 38 | def getUser(self, user_id, **kwargs): # noqa: E501 39 | """ # noqa: E501 40 | 41 | The User Profile endpoint returns information about the Instagram user that has authorized with the application. # noqa: E501 42 | This method makes a synchronous HTTP request by default. To make an 43 | asynchronous HTTP request, please pass async_req=True 44 | >>> thread = api.getUser(user_id, async_req=True) 45 | >>> result = thread.get() 46 | 47 | :param async_req bool 48 | :param integer user_id: the user id (or the logged_in_user.pk in login() response) 49 | (required) 50 | :return: object 51 | If the method is called asynchronously, 52 | returns the request thread. 53 | """ 54 | kwargs['_return_http_data_only'] = True 55 | if kwargs.get('async_req'): 56 | return self.getUser_with_http_info(user_id, **kwargs) # noqa: E501 57 | else: 58 | (data) = self.getUser_with_http_info(user_id, **kwargs) # noqa: E501 59 | return data 60 | 61 | def getUser_with_http_info(self, user_id, **kwargs): # noqa: E501 62 | """ # noqa: E501 63 | 64 | The User Profile endpoint returns information about the Instagram user that has authorized with the application. # noqa: E501 65 | This method makes a synchronous HTTP request by default. To make an 66 | asynchronous HTTP request, please pass async_req=True 67 | >>> thread = api.getUser_with_http_info(user_id, async_req=True) 68 | >>> result = thread.get() 69 | 70 | :param async_req bool 71 | :param integer user_id: the user id (or the logged_in_user.pk in login() response) 72 | (required) 73 | :return: object 74 | If the method is called asynchronously, 75 | returns the request thread. 76 | """ 77 | 78 | local_var_params = locals() 79 | 80 | all_params = ['user_id'] # noqa: E501 81 | all_params.append('async_req') 82 | all_params.append('_return_http_data_only') 83 | all_params.append('_preload_content') 84 | all_params.append('_request_timeout') 85 | 86 | for key, val in six.iteritems(local_var_params['kwargs']): 87 | if key not in all_params: 88 | raise ApiTypeError( 89 | "Got an unexpected keyword argument '%s'" 90 | " to method getUser" % key 91 | ) 92 | local_var_params[key] = val 93 | del local_var_params['kwargs'] 94 | # verify the required parameter 'user_id' is set 95 | if ('user_id' not in local_var_params or 96 | local_var_params['user_id'] is None): 97 | raise ApiValueError("Missing the required parameter `user_id` when calling `getUser`") # noqa: E501 98 | 99 | collection_formats = {} 100 | 101 | path_params = {} 102 | if 'user_id' in local_var_params: 103 | path_params['user_id'] = local_var_params['user_id'] # noqa: E501 104 | 105 | query_params = [] 106 | 107 | header_params = {} 108 | 109 | form_params = [] 110 | local_var_files = {} 111 | 112 | body_params = None 113 | # HTTP header `Accept` 114 | header_params['Accept'] = self.api_client.select_header_accept( 115 | ['application/json', 'application/json']) # noqa: E501 116 | 117 | # HTTP header `Content-Type` 118 | header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 119 | ['application/x-www-form-urlencoded']) # noqa: E501 120 | 121 | # Authentication setting 122 | auth_settings = [] # noqa: E501 123 | 124 | return self.api_client.call_api( 125 | '/users/{user_id}/info/', 'GET', 126 | path_params, 127 | query_params, 128 | header_params, 129 | body=body_params, 130 | post_params=form_params, 131 | files=local_var_files, 132 | response_type='object', # noqa: E501 133 | auth_settings=auth_settings, 134 | async_req=local_var_params.get('async_req'), 135 | _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 136 | _preload_content=local_var_params.get('_preload_content', True), 137 | _request_timeout=local_var_params.get('_request_timeout'), 138 | collection_formats=collection_formats) 139 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/api/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | # flake8: noqa 4 | 5 | # import apis into api package 6 | from private_instagram_sdk.api.Auth import AuthApi 7 | from private_instagram_sdk.api.User import UserApi 8 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/exceptions.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | import six 13 | 14 | 15 | class OpenApiException(Exception): 16 | """The base exception class for all OpenAPIExceptions""" 17 | 18 | 19 | class ApiTypeError(OpenApiException, TypeError): 20 | def __init__(self, msg, path_to_item=None, valid_classes=None, 21 | key_type=None): 22 | """ Raises an exception for TypeErrors 23 | 24 | Args: 25 | msg (str): the exception message 26 | 27 | Keyword Args: 28 | path_to_item (list): a list of keys an indices to get to the 29 | current_item 30 | None if unset 31 | valid_classes (tuple): the primitive classes that current item 32 | should be an instance of 33 | None if unset 34 | key_type (bool): False if our value is a value in a dict 35 | True if it is a key in a dict 36 | False if our item is an item in a list 37 | None if unset 38 | """ 39 | self.path_to_item = path_to_item 40 | self.valid_classes = valid_classes 41 | self.key_type = key_type 42 | full_msg = msg 43 | if path_to_item: 44 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 45 | super(ApiTypeError, self).__init__(full_msg) 46 | 47 | 48 | class ApiValueError(OpenApiException, ValueError): 49 | def __init__(self, msg, path_to_item=None): 50 | """ 51 | Args: 52 | msg (str): the exception message 53 | 54 | Keyword Args: 55 | path_to_item (list) the path to the exception in the 56 | received_data dict. None if unset 57 | """ 58 | 59 | self.path_to_item = path_to_item 60 | full_msg = msg 61 | if path_to_item: 62 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 63 | super(ApiValueError, self).__init__(full_msg) 64 | 65 | 66 | class ApiKeyError(OpenApiException, KeyError): 67 | def __init__(self, msg, path_to_item=None): 68 | """ 69 | Args: 70 | msg (str): the exception message 71 | 72 | Keyword Args: 73 | path_to_item (None/list) the path to the exception in the 74 | received_data dict 75 | """ 76 | self.path_to_item = path_to_item 77 | full_msg = msg 78 | if path_to_item: 79 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 80 | super(ApiKeyError, self).__init__(full_msg) 81 | 82 | 83 | class ApiException(OpenApiException): 84 | 85 | def __init__(self, status=None, reason=None, http_resp=None): 86 | if http_resp: 87 | self.status = http_resp.status 88 | self.reason = http_resp.reason 89 | self.body = http_resp.data 90 | self.headers = http_resp.getheaders() 91 | else: 92 | self.status = status 93 | self.reason = reason 94 | self.body = None 95 | self.headers = None 96 | 97 | def __str__(self): 98 | """Custom error messages for exception""" 99 | error_message = "({0})\n"\ 100 | "Reason: {1}\n".format(self.status, self.reason) 101 | if self.headers: 102 | error_message += "HTTP response headers: {0}\n".format( 103 | self.headers) 104 | 105 | if self.body: 106 | error_message += "HTTP response body: {0}\n".format(self.body) 107 | 108 | return error_message 109 | 110 | 111 | def render_path(path_to_item): 112 | """Returns a string representation of a path""" 113 | result = "" 114 | for pth in path_to_item: 115 | if isinstance(pth, six.integer_types): 116 | result += "[{0}]".format(pth) 117 | else: 118 | result += "['{0}']".format(pth) 119 | return result 120 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/models/AuthBody.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | import pprint 13 | import re # noqa: F401 14 | 15 | import six 16 | 17 | 18 | class AuthBody(object): 19 | """NOTE: This class is auto generated by OpenAPI Generator. 20 | Ref: https://openapi-generator.tech 21 | 22 | Do not edit the class manually. 23 | """ 24 | """ 25 | Attributes: 26 | openapi_types (dict): The key is attribute name 27 | and the value is attribute type. 28 | attribute_map (dict): The key is attribute name 29 | and the value is json key in definition. 30 | """ 31 | openapi_types = { 32 | 'ig_sig_key_version': '', 33 | 'signed_body': '' 34 | } 35 | 36 | attribute_map = { 37 | 'ig_sig_key_version': 'ig_sig_key_version', 38 | 'signed_body': 'signed_body' 39 | } 40 | 41 | def __init__(self, ig_sig_key_version=None, signed_body=None): # noqa: E501 42 | """AuthBody - a model defined in OpenAPI""" # noqa: E501 43 | self._ig_sig_key_version = None 44 | self._signed_body = None 45 | self.discriminator = None 46 | if ig_sig_key_version is not None: 47 | self.ig_sig_key_version = ig_sig_key_version 48 | if signed_body is not None: 49 | self.signed_body = signed_body 50 | 51 | @property 52 | def ig_sig_key_version(self): 53 | """Gets the ig_sig_key_version of this AuthBody. # noqa: E501 54 | 55 | 56 | :return: The ig_sig_key_version of this AuthBody. # noqa: E501 57 | :rtype: 58 | """ 59 | return self._ig_sig_key_version 60 | 61 | @ig_sig_key_version.setter 62 | def ig_sig_key_version(self, ig_sig_key_version): 63 | """Sets the ig_sig_key_version of this AuthBody. 64 | 65 | 66 | :param ig_sig_key_version: The ig_sig_key_version of this AuthBody. # noqa: E501 67 | :type: 68 | """ 69 | 70 | self._ig_sig_key_version = ig_sig_key_version 71 | 72 | @property 73 | def signed_body(self): 74 | """Gets the signed_body of this AuthBody. # noqa: E501 75 | 76 | 77 | :return: The signed_body of this AuthBody. # noqa: E501 78 | :rtype: 79 | """ 80 | return self._signed_body 81 | 82 | @signed_body.setter 83 | def signed_body(self, signed_body): 84 | """Sets the signed_body of this AuthBody. 85 | 86 | 87 | :param signed_body: The signed_body of this AuthBody. # noqa: E501 88 | :type: 89 | """ 90 | 91 | self._signed_body = signed_body 92 | 93 | def to_dict(self): 94 | """Returns the model properties as a dict""" 95 | result = {} 96 | 97 | for attr, _ in six.iteritems(self.openapi_types): 98 | value = getattr(self, attr) 99 | if isinstance(value, list): 100 | result[attr] = list(map( 101 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 102 | value 103 | )) 104 | elif hasattr(value, "to_dict"): 105 | result[attr] = value.to_dict() 106 | elif isinstance(value, dict): 107 | result[attr] = dict(map( 108 | lambda item: (item[0], item[1].to_dict()) 109 | if hasattr(item[1], "to_dict") else item, 110 | value.items() 111 | )) 112 | else: 113 | result[attr] = value 114 | 115 | return result 116 | 117 | def to_str(self): 118 | """Returns the string representation of the model""" 119 | return pprint.pformat(self.to_dict()) 120 | 121 | def __repr__(self): 122 | """For `print` and `pprint`""" 123 | return self.to_str() 124 | 125 | def __eq__(self, other): 126 | """Returns true if both objects are equal""" 127 | if not isinstance(other, AuthBody): 128 | return False 129 | 130 | return self.__dict__ == other.__dict__ 131 | 132 | def __ne__(self, other): 133 | """Returns true if both objects are not equal""" 134 | return not self == other 135 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/models/JsonObject.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | import pprint 13 | import re # noqa: F401 14 | 15 | import six 16 | 17 | 18 | class JsonObject(object): 19 | """NOTE: This class is auto generated by OpenAPI Generator. 20 | Ref: https://openapi-generator.tech 21 | 22 | Do not edit the class manually. 23 | """ 24 | """ 25 | Attributes: 26 | openapi_types (dict): The key is attribute name 27 | and the value is attribute type. 28 | attribute_map (dict): The key is attribute name 29 | and the value is json key in definition. 30 | """ 31 | openapi_types = { 32 | 'message': '', 33 | 'status': '', 34 | 'error_type': '' 35 | } 36 | 37 | attribute_map = { 38 | 'message': 'message', 39 | 'status': 'status', 40 | 'error_type': 'error_type' 41 | } 42 | 43 | def __init__(self, message=None, status=None, error_type=None): # noqa: E501 44 | """JsonObject - a model defined in OpenAPI""" # noqa: E501 45 | self._message = None 46 | self._status = None 47 | self._error_type = None 48 | self.discriminator = None 49 | if message is not None: 50 | self.message = message 51 | if status is not None: 52 | self.status = status 53 | if error_type is not None: 54 | self.error_type = error_type 55 | 56 | @property 57 | def message(self): 58 | """Gets the message of this JsonObject. # noqa: E501 59 | 60 | 61 | :return: The message of this JsonObject. # noqa: E501 62 | :rtype: 63 | """ 64 | return self._message 65 | 66 | @message.setter 67 | def message(self, message): 68 | """Sets the message of this JsonObject. 69 | 70 | 71 | :param message: The message of this JsonObject. # noqa: E501 72 | :type: 73 | """ 74 | 75 | self._message = message 76 | 77 | @property 78 | def status(self): 79 | """Gets the status of this JsonObject. # noqa: E501 80 | 81 | 82 | :return: The status of this JsonObject. # noqa: E501 83 | :rtype: 84 | """ 85 | return self._status 86 | 87 | @status.setter 88 | def status(self, status): 89 | """Sets the status of this JsonObject. 90 | 91 | 92 | :param status: The status of this JsonObject. # noqa: E501 93 | :type: 94 | """ 95 | 96 | self._status = status 97 | 98 | @property 99 | def error_type(self): 100 | """Gets the error_type of this JsonObject. # noqa: E501 101 | 102 | 103 | :return: The error_type of this JsonObject. # noqa: E501 104 | :rtype: 105 | """ 106 | return self._error_type 107 | 108 | @error_type.setter 109 | def error_type(self, error_type): 110 | """Sets the error_type of this JsonObject. 111 | 112 | 113 | :param error_type: The error_type of this JsonObject. # noqa: E501 114 | :type: 115 | """ 116 | 117 | self._error_type = error_type 118 | 119 | def to_dict(self): 120 | """Returns the model properties as a dict""" 121 | result = {} 122 | 123 | for attr, _ in six.iteritems(self.openapi_types): 124 | value = getattr(self, attr) 125 | if isinstance(value, list): 126 | result[attr] = list(map( 127 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 128 | value 129 | )) 130 | elif hasattr(value, "to_dict"): 131 | result[attr] = value.to_dict() 132 | elif isinstance(value, dict): 133 | result[attr] = dict(map( 134 | lambda item: (item[0], item[1].to_dict()) 135 | if hasattr(item[1], "to_dict") else item, 136 | value.items() 137 | )) 138 | else: 139 | result[attr] = value 140 | 141 | return result 142 | 143 | def to_str(self): 144 | """Returns the string representation of the model""" 145 | return pprint.pformat(self.to_dict()) 146 | 147 | def __repr__(self): 148 | """For `print` and `pprint`""" 149 | return self.to_str() 150 | 151 | def __eq__(self, other): 152 | """Returns true if both objects are equal""" 153 | if not isinstance(other, JsonObject): 154 | return False 155 | 156 | return self.__dict__ == other.__dict__ 157 | 158 | def __ne__(self, other): 159 | """Returns true if both objects are not equal""" 160 | return not self == other 161 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/models/__init__.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | """ 5 | Instagram API 6 | 7 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 8 | 9 | OpenAPI spec version: 0.0.1 10 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 11 | """ 12 | 13 | from __future__ import absolute_import 14 | 15 | # import models into model package 16 | from private_instagram_sdk.models.User import User 17 | from private_instagram_sdk.models.Error import Error 18 | from private_instagram_sdk.models.JsonObject import JsonObject 19 | from private_instagram_sdk.models.AuthBody import AuthBody 20 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/models/error.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | import pprint 13 | import re # noqa: F401 14 | 15 | import six 16 | 17 | 18 | class Error(object): 19 | """NOTE: This class is auto generated by OpenAPI Generator. 20 | Ref: https://openapi-generator.tech 21 | 22 | Do not edit the class manually. 23 | """ 24 | """ 25 | Attributes: 26 | openapi_types (dict): The key is attribute name 27 | and the value is attribute type. 28 | attribute_map (dict): The key is attribute name 29 | and the value is json key in definition. 30 | """ 31 | openapi_types = { 32 | 'message': '', 33 | 'status': '', 34 | 'error_type': '' 35 | } 36 | 37 | attribute_map = { 38 | 'message': 'message', 39 | 'status': 'status', 40 | 'error_type': 'error_type' 41 | } 42 | 43 | def __init__(self, message=None, status=None, error_type=None): # noqa: E501 44 | """Error - a model defined in OpenAPI""" # noqa: E501 45 | self._message = None 46 | self._status = None 47 | self._error_type = None 48 | self.discriminator = None 49 | if message is not None: 50 | self.message = message 51 | if status is not None: 52 | self.status = status 53 | if error_type is not None: 54 | self.error_type = error_type 55 | 56 | @property 57 | def message(self): 58 | """Gets the message of this Error. # noqa: E501 59 | 60 | 61 | :return: The message of this Error. # noqa: E501 62 | :rtype: 63 | """ 64 | return self._message 65 | 66 | @message.setter 67 | def message(self, message): 68 | """Sets the message of this Error. 69 | 70 | 71 | :param message: The message of this Error. # noqa: E501 72 | :type: 73 | """ 74 | 75 | self._message = message 76 | 77 | @property 78 | def status(self): 79 | """Gets the status of this Error. # noqa: E501 80 | 81 | 82 | :return: The status of this Error. # noqa: E501 83 | :rtype: 84 | """ 85 | return self._status 86 | 87 | @status.setter 88 | def status(self, status): 89 | """Sets the status of this Error. 90 | 91 | 92 | :param status: The status of this Error. # noqa: E501 93 | :type: 94 | """ 95 | 96 | self._status = status 97 | 98 | @property 99 | def error_type(self): 100 | """Gets the error_type of this Error. # noqa: E501 101 | 102 | 103 | :return: The error_type of this Error. # noqa: E501 104 | :rtype: 105 | """ 106 | return self._error_type 107 | 108 | @error_type.setter 109 | def error_type(self, error_type): 110 | """Sets the error_type of this Error. 111 | 112 | 113 | :param error_type: The error_type of this Error. # noqa: E501 114 | :type: 115 | """ 116 | 117 | self._error_type = error_type 118 | 119 | def to_dict(self): 120 | """Returns the model properties as a dict""" 121 | result = {} 122 | 123 | for attr, _ in six.iteritems(self.openapi_types): 124 | value = getattr(self, attr) 125 | if isinstance(value, list): 126 | result[attr] = list(map( 127 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 128 | value 129 | )) 130 | elif hasattr(value, "to_dict"): 131 | result[attr] = value.to_dict() 132 | elif isinstance(value, dict): 133 | result[attr] = dict(map( 134 | lambda item: (item[0], item[1].to_dict()) 135 | if hasattr(item[1], "to_dict") else item, 136 | value.items() 137 | )) 138 | else: 139 | result[attr] = value 140 | 141 | return result 142 | 143 | def to_str(self): 144 | """Returns the string representation of the model""" 145 | return pprint.pformat(self.to_dict()) 146 | 147 | def __repr__(self): 148 | """For `print` and `pprint`""" 149 | return self.to_str() 150 | 151 | def __eq__(self, other): 152 | """Returns true if both objects are equal""" 153 | if not isinstance(other, Error): 154 | return False 155 | 156 | return self.__dict__ == other.__dict__ 157 | 158 | def __ne__(self, other): 159 | """Returns true if both objects are not equal""" 160 | return not self == other 161 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/models/user.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | import pprint 13 | import re # noqa: F401 14 | 15 | import six 16 | 17 | 18 | class User(object): 19 | """NOTE: This class is auto generated by OpenAPI Generator. 20 | Ref: https://openapi-generator.tech 21 | 22 | Do not edit the class manually. 23 | """ 24 | """ 25 | Attributes: 26 | openapi_types (dict): The key is attribute name 27 | and the value is attribute type. 28 | attribute_map (dict): The key is attribute name 29 | and the value is json key in definition. 30 | """ 31 | openapi_types = { 32 | 'username': '' 33 | } 34 | 35 | attribute_map = { 36 | 'username': 'username' 37 | } 38 | 39 | def __init__(self, username=None): # noqa: E501 40 | """User - a model defined in OpenAPI""" # noqa: E501 41 | self._username = None 42 | self.discriminator = None 43 | if username is not None: 44 | self.username = username 45 | 46 | @property 47 | def username(self): 48 | """Gets the username of this User. # noqa: E501 49 | 50 | 51 | :return: The username of this User. # noqa: E501 52 | :rtype: 53 | """ 54 | return self._username 55 | 56 | @username.setter 57 | def username(self, username): 58 | """Sets the username of this User. 59 | 60 | 61 | :param username: The username of this User. # noqa: E501 62 | :type: 63 | """ 64 | 65 | self._username = username 66 | 67 | def to_dict(self): 68 | """Returns the model properties as a dict""" 69 | result = {} 70 | 71 | for attr, _ in six.iteritems(self.openapi_types): 72 | value = getattr(self, attr) 73 | if isinstance(value, list): 74 | result[attr] = list(map( 75 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 76 | value 77 | )) 78 | elif hasattr(value, "to_dict"): 79 | result[attr] = value.to_dict() 80 | elif isinstance(value, dict): 81 | result[attr] = dict(map( 82 | lambda item: (item[0], item[1].to_dict()) 83 | if hasattr(item[1], "to_dict") else item, 84 | value.items() 85 | )) 86 | else: 87 | result[attr] = value 88 | 89 | return result 90 | 91 | def to_str(self): 92 | """Returns the string representation of the model""" 93 | return pprint.pformat(self.to_dict()) 94 | 95 | def __repr__(self): 96 | """For `print` and `pprint`""" 97 | return self.to_str() 98 | 99 | def __eq__(self, other): 100 | """Returns true if both objects are equal""" 101 | if not isinstance(other, User): 102 | return False 103 | 104 | return self.__dict__ == other.__dict__ 105 | 106 | def __ne__(self, other): 107 | """Returns true if both objects are not equal""" 108 | return not self == other 109 | -------------------------------------------------------------------------------- /sdks/python/private_instagram_sdk/rest.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | from __future__ import absolute_import 13 | 14 | import io 15 | import json 16 | import logging 17 | import re 18 | import ssl 19 | 20 | import certifi 21 | # python 2 and python 3 compatibility library 22 | import six 23 | from six.moves.urllib.parse import urlencode 24 | import urllib3 25 | import requests 26 | 27 | from private_instagram_sdk.exceptions import ApiException, ApiValueError 28 | 29 | 30 | logger = logging.getLogger(__name__) 31 | 32 | 33 | class RESTResponse(io.IOBase): 34 | 35 | def __init__(self, resp): 36 | self.urllib3_response = resp 37 | self.status = resp.status 38 | self.reason = resp.reason 39 | self.data = resp.data 40 | 41 | def getheaders(self): 42 | """Returns a dictionary of the response headers.""" 43 | return self.urllib3_response.getheaders() 44 | 45 | def getheader(self, name, default=None): 46 | """Returns a given response header.""" 47 | return self.urllib3_response.getheader(name, default) 48 | 49 | 50 | class RESTClientObject(object): 51 | 52 | def __init__(self, configuration, pools_size=4, maxsize=None): 53 | # urllib3.PoolManager will pass all kw parameters to connectionpool 54 | # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 55 | # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 56 | # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 57 | # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 58 | 59 | # Session requests manager 60 | self.session = requests.Session() 61 | 62 | # cert_reqs 63 | if configuration.verify_ssl: 64 | cert_reqs = ssl.CERT_REQUIRED 65 | else: 66 | cert_reqs = ssl.CERT_NONE 67 | 68 | # ca_certs 69 | if configuration.ssl_ca_cert: 70 | ca_certs = configuration.ssl_ca_cert 71 | else: 72 | # if not set certificate file, use Mozilla's root certificates. 73 | ca_certs = certifi.where() 74 | 75 | addition_pool_args = {} 76 | if configuration.assert_hostname is not None: 77 | addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 78 | 79 | if configuration.retries is not None: 80 | addition_pool_args['retries'] = configuration.retries 81 | 82 | if maxsize is None: 83 | if configuration.connection_pool_maxsize is not None: 84 | maxsize = configuration.connection_pool_maxsize 85 | else: 86 | maxsize = 4 87 | 88 | 89 | def request(self, method, url, query_params=None, headers=None, 90 | body=None, post_params=None, _preload_content=True, 91 | _request_timeout=None): 92 | """Perform requests. 93 | 94 | :param method: http request method 95 | :param url: http request url 96 | :param query_params: query parameters in the url 97 | :param headers: http request headers 98 | :param body: request json body, for `application/json` 99 | :param post_params: request post parameters, 100 | `application/x-www-form-urlencoded` 101 | and `multipart/form-data` 102 | :param _preload_content: if False, the urllib3.HTTPResponse object will 103 | be returned without reading/decoding response 104 | data. Default is True. 105 | :param _request_timeout: timeout setting for this request. If one 106 | number provided, it will be total request 107 | timeout. It can also be a pair (tuple) of 108 | (connection, read) timeouts. 109 | """ 110 | method = method.upper() 111 | assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 112 | 'PATCH', 'OPTIONS'] 113 | 114 | if post_params and body: 115 | raise ApiValueError( 116 | "body parameter cannot be used with post_params parameter." 117 | ) 118 | 119 | post_params = post_params or {} 120 | headers = headers or {} 121 | 122 | timeout = None 123 | if _request_timeout: 124 | if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 125 | timeout = urllib3.Timeout(total=_request_timeout) 126 | elif (isinstance(_request_timeout, tuple) and 127 | len(_request_timeout) == 2): 128 | timeout = urllib3.Timeout( 129 | connect=_request_timeout[0], read=_request_timeout[1]) 130 | 131 | if 'Content-Type' not in headers: 132 | headers['Content-Type'] = 'application/json' 133 | 134 | data = '' 135 | if post_params: 136 | data = '&'.join([ '='.join(str(el) for el in par) for par in post_params]) 137 | if body: 138 | data = body 139 | 140 | try: 141 | # print('####') 142 | # print('Build the session request with:') 143 | # print('method: ', method) 144 | # print('url: ', url) 145 | # print('headers: ', headers) 146 | # print('query_params: ', query_params) 147 | # print('post_params: ', post_params) 148 | # print('body: ', body) 149 | # print('data: ', data) 150 | # print('####') 151 | 152 | self.session.headers.update(headers) 153 | 154 | r = self.session.request(method, url, data=data) 155 | 156 | # print('Request sent from session is: ', r.request) 157 | # print('url: ', r.request.url) 158 | # print('headers: ', r.request.headers) 159 | # print('body: ', r.request.body) 160 | 161 | # print('Response from session is: ', r) 162 | # print('url: ', r.url) 163 | # print('status_code: ', r.status_code) 164 | # print('headers: ', r.headers) 165 | # print('text: ', r.text) 166 | # print('cookies: ', r.cookies) 167 | except Exception as e: 168 | print('exception is: ', e) 169 | 170 | return r 171 | 172 | def GET(self, url, headers=None, query_params=None, _preload_content=True, 173 | _request_timeout=None): 174 | return self.request("GET", url, 175 | headers=headers, 176 | _preload_content=_preload_content, 177 | _request_timeout=_request_timeout, 178 | query_params=query_params) 179 | 180 | def HEAD(self, url, headers=None, query_params=None, _preload_content=True, 181 | _request_timeout=None): 182 | return self.request("HEAD", url, 183 | headers=headers, 184 | _preload_content=_preload_content, 185 | _request_timeout=_request_timeout, 186 | query_params=query_params) 187 | 188 | def OPTIONS(self, url, headers=None, query_params=None, post_params=None, 189 | body=None, _preload_content=True, _request_timeout=None): 190 | return self.request("OPTIONS", url, 191 | headers=headers, 192 | query_params=query_params, 193 | post_params=post_params, 194 | _preload_content=_preload_content, 195 | _request_timeout=_request_timeout, 196 | body=body) 197 | 198 | def DELETE(self, url, headers=None, query_params=None, body=None, 199 | _preload_content=True, _request_timeout=None): 200 | return self.request("DELETE", url, 201 | headers=headers, 202 | query_params=query_params, 203 | _preload_content=_preload_content, 204 | _request_timeout=_request_timeout, 205 | body=body) 206 | 207 | def POST(self, url, headers=None, query_params=None, post_params=None, 208 | body=None, _preload_content=True, _request_timeout=None): 209 | return self.request("POST", url, 210 | headers=headers, 211 | query_params=query_params, 212 | post_params=post_params, 213 | _preload_content=_preload_content, 214 | _request_timeout=_request_timeout, 215 | body=body) 216 | 217 | def PUT(self, url, headers=None, query_params=None, post_params=None, 218 | body=None, _preload_content=True, _request_timeout=None): 219 | return self.request("PUT", url, 220 | headers=headers, 221 | query_params=query_params, 222 | post_params=post_params, 223 | _preload_content=_preload_content, 224 | _request_timeout=_request_timeout, 225 | body=body) 226 | 227 | def PATCH(self, url, headers=None, query_params=None, post_params=None, 228 | body=None, _preload_content=True, _request_timeout=None): 229 | return self.request("PATCH", url, 230 | headers=headers, 231 | query_params=query_params, 232 | post_params=post_params, 233 | _preload_content=_preload_content, 234 | _request_timeout=_request_timeout, 235 | body=body) 236 | -------------------------------------------------------------------------------- /sdks/python/requirements.txt: -------------------------------------------------------------------------------- 1 | certifi >= 14.05.14 2 | six >= 1.10 3 | python_dateutil >= 2.5.3 4 | setuptools >= 21.0.0 5 | urllib3 >= 1.15.1 6 | -------------------------------------------------------------------------------- /sdks/python/setup.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | from setuptools import setup, find_packages # noqa: H301 13 | 14 | NAME = "private_instagram_sdk" 15 | VERSION = "1.0.0" 16 | # To install the library, run the following 17 | # 18 | # python setup.py install 19 | # 20 | # prerequisite: setuptools 21 | # http://pypi.python.org/pypi/setuptools 22 | 23 | REQUIRES = ["urllib3 >= 1.15", "requests", "six >= 1.10", "certifi", "python-dateutil"] 24 | 25 | setup( 26 | name=NAME, 27 | version=VERSION, 28 | description="Instagram API", 29 | author_email="", 30 | url="https://github.com/instagrambot/instagram-api-toolkit", 31 | keywords=["OpenAPI", "OpenAPI-Generator", "Instagram API"], 32 | install_requires=REQUIRES, 33 | packages=find_packages(), 34 | include_package_data=True, 35 | long_description="""\ 36 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 37 | """ 38 | ) 39 | -------------------------------------------------------------------------------- /sdks/python/test-requirements.txt: -------------------------------------------------------------------------------- 1 | coverage>=4.0.3 2 | nose>=1.3.7 3 | pluggy>=0.3.1 4 | py>=1.4.31 5 | randomize>=0.13 6 | -------------------------------------------------------------------------------- /sdks/python/test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b3nab/instagram-api-toolkit/b68a52e1a3cfa4f1b67850d13f502e82b5743304/sdks/python/test/__init__.py -------------------------------------------------------------------------------- /sdks/python/test/test_AuthBody.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | from __future__ import absolute_import 13 | 14 | import unittest 15 | 16 | import private_instagram_sdk 17 | from AuthBody.clsAuthBody import AuthBody # noqa: E501 18 | from private_instagram_sdk.rest import ApiException 19 | 20 | 21 | class TestAuthBody(unittest.TestCase): 22 | """AuthBody unit test stubs""" 23 | 24 | def setUp(self): 25 | pass 26 | 27 | def tearDown(self): 28 | pass 29 | 30 | def testAuthBody(self): 31 | """Test AuthBody""" 32 | # FIXME: construct object with mandatory attributes with example values 33 | # model = private_instagram_sdk.models.clsAuthBody.AuthBody() # noqa: E501 34 | pass 35 | 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /sdks/python/test/test_JsonObject.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | from __future__ import absolute_import 13 | 14 | import unittest 15 | 16 | import private_instagram_sdk 17 | from JsonObject.clsJsonObject import JsonObject # noqa: E501 18 | from private_instagram_sdk.rest import ApiException 19 | 20 | 21 | class TestJsonObject(unittest.TestCase): 22 | """JsonObject unit test stubs""" 23 | 24 | def setUp(self): 25 | pass 26 | 27 | def tearDown(self): 28 | pass 29 | 30 | def testJsonObject(self): 31 | """Test JsonObject""" 32 | # FIXME: construct object with mandatory attributes with example values 33 | # model = private_instagram_sdk.models.clsJsonObject.JsonObject() # noqa: E501 34 | pass 35 | 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /sdks/python/test/test_error.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | from __future__ import absolute_import 13 | 14 | import unittest 15 | 16 | import private_instagram_sdk 17 | from Error.clsError import Error # noqa: E501 18 | from private_instagram_sdk.rest import ApiException 19 | 20 | 21 | class TestError(unittest.TestCase): 22 | """Error unit test stubs""" 23 | 24 | def setUp(self): 25 | pass 26 | 27 | def tearDown(self): 28 | pass 29 | 30 | def testError(self): 31 | """Test Error""" 32 | # FIXME: construct object with mandatory attributes with example values 33 | # model = private_instagram_sdk.models.clsError.Error() # noqa: E501 34 | pass 35 | 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /sdks/python/test/test_user.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | """ 4 | Instagram API 5 | 6 | The Instagram Private API in OpenAPI specs.v3.0 # noqa: E501 7 | 8 | OpenAPI spec version: 0.0.1 9 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 10 | """ 11 | 12 | from __future__ import absolute_import 13 | 14 | import unittest 15 | 16 | import private_instagram_sdk 17 | from User.clsUser import User # noqa: E501 18 | from private_instagram_sdk.rest import ApiException 19 | 20 | 21 | class TestUser(unittest.TestCase): 22 | """User unit test stubs""" 23 | 24 | def setUp(self): 25 | pass 26 | 27 | def tearDown(self): 28 | pass 29 | 30 | def testUser(self): 31 | """Test User""" 32 | # FIXME: construct object with mandatory attributes with example values 33 | # model = private_instagram_sdk.models.clsUser.User() # noqa: E501 34 | pass 35 | 36 | 37 | if __name__ == '__main__': 38 | unittest.main() 39 | -------------------------------------------------------------------------------- /sdks/python/tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py27, py3 3 | 4 | [testenv] 5 | deps=-r{toxinidir}/requirements.txt 6 | -r{toxinidir}/test-requirements.txt 7 | 8 | commands= 9 | nosetests \ 10 | [] 11 | -------------------------------------------------------------------------------- /social-preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b3nab/instagram-api-toolkit/b68a52e1a3cfa4f1b67850d13f502e82b5743304/social-preview.png -------------------------------------------------------------------------------- /templates/python/.svn/entries: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /templates/python/.svn/format: -------------------------------------------------------------------------------- 1 | 12 2 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/20/20db0342b0834a15b3dec124f5247aed1ff5210f.svn-base: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | venv/ 48 | .python-version 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | 57 | # Sphinx documentation 58 | docs/_build/ 59 | 60 | # PyBuilder 61 | target/ 62 | 63 | #Ipython Notebook 64 | .ipynb_checkpoints 65 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/22/2266be0be68af27ee0e4907a25ff11ab790f1aeb.svn-base: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | from setuptools import setup, find_packages # noqa: H301 6 | 7 | NAME = "{{{projectName}}}" 8 | VERSION = "{{packageVersion}}" 9 | {{#apiInfo}} 10 | {{#apis}} 11 | {{^hasMore}} 12 | # To install the library, run the following 13 | # 14 | # python setup.py install 15 | # 16 | # prerequisite: setuptools 17 | # http://pypi.python.org/pypi/setuptools 18 | 19 | REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"] 20 | {{#asyncio}} 21 | REQUIRES.append("aiohttp >= 3.0.0") 22 | {{/asyncio}} 23 | {{#tornado}} 24 | REQUIRES.append("tornado>=4.2,<5") 25 | {{/tornado}} 26 | 27 | setup( 28 | name=NAME, 29 | version=VERSION, 30 | description="{{appName}}", 31 | author_email="{{infoEmail}}", 32 | url="{{packageUrl}}", 33 | keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], 34 | install_requires=REQUIRES, 35 | packages=find_packages(), 36 | include_package_data=True, 37 | long_description="""\ 38 | {{appDescription}} # noqa: E501 39 | """ 40 | ) 41 | {{/hasMore}} 42 | {{/apis}} 43 | {{/apiInfo}} 44 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/27/27320fa2f9d3d1e1fe9b7519f2cdd043d58d1011.svn-base: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | # flake8: noqa 4 | 5 | # import apis into api package 6 | {{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} 7 | {{/apis}}{{/apiInfo}} -------------------------------------------------------------------------------- /templates/python/.svn/pristine/2a/2acf5085b6ced6e12cd5c8ea4610131dc705d936.svn-base: -------------------------------------------------------------------------------- 1 | # {{packageName}}.{{classname}}{{#description}} 2 | {{description}}{{/description}} 3 | 4 | All URIs are relative to *{{basePath}}* 5 | 6 | Method | HTTP request | Description 7 | ------------- | ------------- | ------------- 8 | {{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} 9 | {{/operation}}{{/operations}} 10 | 11 | {{#operations}} 12 | {{#operation}} 13 | # **{{{operationId}}}** 14 | > {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) 15 | 16 | {{{summary}}}{{#notes}} 17 | 18 | {{{notes}}}{{/notes}} 19 | 20 | ### Example 21 | 22 | {{#hasAuthMethods}} 23 | {{#authMethods}} 24 | {{#isBasic}} 25 | {{^isBasicBearer}} 26 | * Basic Authentication ({{name}}): 27 | {{/isBasicBearer}} 28 | {{#isBasicBearer}} 29 | * Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} Authentication ({{name}}): 30 | {{/isBasicBearer}} 31 | {{/isBasic}} 32 | {{#isApiKey}} 33 | * Api Key Authentication ({{name}}): 34 | {{/isApiKey }} 35 | {{#isOAuth}} 36 | * OAuth Authentication ({{name}}): 37 | {{/isOAuth }} 38 | {{> api_doc_example }} 39 | {{/authMethods}} 40 | {{/hasAuthMethods}} 41 | {{^hasAuthMethods}} 42 | {{> api_doc_example }} 43 | {{/hasAuthMethods}} 44 | ### Parameters 45 | {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} 46 | Name | Type | Description | Notes 47 | ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} 48 | {{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} 49 | {{/allParams}} 50 | 51 | ### Return type 52 | 53 | {{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} 54 | 55 | ### Authorization 56 | 57 | {{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} 58 | 59 | ### HTTP request headers 60 | 61 | - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} 62 | - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} 63 | 64 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 65 | 66 | {{/operation}} 67 | {{/operations}} 68 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/32/320ddb91c3753a832fe6126f9ff68a14808205e0.svn-base: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | from __future__ import absolute_import 6 | 7 | import unittest 8 | 9 | {{#models}} 10 | {{#model}} 11 | import {{packageName}} 12 | from {{modelPackage}}.{{classFilename}} import {{classname}} # noqa: E501 13 | from {{packageName}}.rest import ApiException 14 | 15 | 16 | class Test{{classname}}(unittest.TestCase): 17 | """{{classname}} unit test stubs""" 18 | 19 | def setUp(self): 20 | pass 21 | 22 | def tearDown(self): 23 | pass 24 | 25 | def test{{classname}}(self): 26 | """Test {{classname}}""" 27 | # FIXME: construct object with mandatory attributes with example values 28 | # model = {{packageName}}.models.{{classFilename}}.{{classname}}() # noqa: E501 29 | pass 30 | 31 | {{/model}} 32 | {{/models}} 33 | 34 | if __name__ == '__main__': 35 | unittest.main() 36 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/33/33c3f6bdd61a1e47b0997f090947c24e078067ab.svn-base: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | import io 6 | import json 7 | import logging 8 | import re 9 | 10 | # python 2 and python 3 compatibility library 11 | import six 12 | from six.moves.urllib.parse import urlencode 13 | import tornado 14 | import tornado.gen 15 | from tornado import httpclient 16 | from urllib3.filepost import encode_multipart_formdata 17 | 18 | from {{packageName}}.exceptions import ApiException, ApiValueError 19 | 20 | logger = logging.getLogger(__name__) 21 | 22 | 23 | class RESTResponse(io.IOBase): 24 | 25 | def __init__(self, resp): 26 | self.tornado_response = resp 27 | self.status = resp.code 28 | self.reason = resp.reason 29 | 30 | if resp.body: 31 | # In Python 3, the response body is utf-8 encoded bytes. 32 | if six.PY3: 33 | self.data = resp.body.decode('utf-8') 34 | else: 35 | self.data = resp.body 36 | else: 37 | self.data = None 38 | 39 | def getheaders(self): 40 | """Returns a CIMultiDictProxy of the response headers.""" 41 | return self.tornado_response.headers 42 | 43 | def getheader(self, name, default=None): 44 | """Returns a given response header.""" 45 | return self.tornado_response.headers.get(name, default) 46 | 47 | 48 | class RESTClientObject(object): 49 | 50 | def __init__(self, configuration, pools_size=4, maxsize=4): 51 | # maxsize is number of requests to host that are allowed in parallel 52 | 53 | self.ca_certs = configuration.ssl_ca_cert 54 | self.client_key = configuration.key_file 55 | self.client_cert = configuration.cert_file 56 | 57 | self.proxy_port = self.proxy_host = None 58 | 59 | # https pool manager 60 | if configuration.proxy: 61 | self.proxy_port = 80 62 | self.proxy_host = configuration.proxy 63 | 64 | self.pool_manager = httpclient.AsyncHTTPClient() 65 | 66 | @tornado.gen.coroutine 67 | def request(self, method, url, query_params=None, headers=None, body=None, 68 | post_params=None, _preload_content=True, 69 | _request_timeout=None): 70 | """Execute Request 71 | 72 | :param method: http request method 73 | :param url: http request url 74 | :param query_params: query parameters in the url 75 | :param headers: http request headers 76 | :param body: request json body, for `application/json` 77 | :param post_params: request post parameters, 78 | `application/x-www-form-urlencoded` 79 | and `multipart/form-data` 80 | :param _preload_content: this is a non-applicable field for 81 | the AiohttpClient. 82 | :param _request_timeout: timeout setting for this request. If one 83 | number provided, it will be total request 84 | timeout. It can also be a pair (tuple) of 85 | (connection, read) timeouts. 86 | """ 87 | method = method.upper() 88 | assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 89 | 'PATCH', 'OPTIONS'] 90 | 91 | if post_params and body: 92 | raise ApiValueError( 93 | "body parameter cannot be used with post_params parameter." 94 | ) 95 | 96 | request = httpclient.HTTPRequest(url) 97 | request.allow_nonstandard_methods = True 98 | request.ca_certs = self.ca_certs 99 | request.client_key = self.client_key 100 | request.client_cert = self.client_cert 101 | request.proxy_host = self.proxy_host 102 | request.proxy_port = self.proxy_port 103 | request.method = method 104 | if headers: 105 | request.headers = headers 106 | if 'Content-Type' not in headers: 107 | request.headers['Content-Type'] = 'application/json' 108 | request.request_timeout = _request_timeout or 5 * 60 109 | 110 | post_params = post_params or {} 111 | 112 | if query_params: 113 | request.url += '?' + urlencode(query_params) 114 | 115 | # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` 116 | if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: 117 | if re.search('json', headers['Content-Type'], re.IGNORECASE): 118 | if body: 119 | body = json.dumps(body) 120 | request.body = body 121 | elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 122 | request.body = urlencode(post_params) 123 | elif headers['Content-Type'] == 'multipart/form-data': 124 | multipart = encode_multipart_formdata(post_params) 125 | request.body, headers['Content-Type'] = multipart 126 | # Pass a `bytes` parameter directly in the body to support 127 | # other content types than Json when `body` argument is provided 128 | # in serialized form 129 | elif isinstance(body, bytes): 130 | request.body = body 131 | else: 132 | # Cannot generate the request from given parameters 133 | msg = """Cannot prepare a request message for provided 134 | arguments. Please check that your arguments match 135 | declared content type.""" 136 | raise ApiException(status=0, reason=msg) 137 | 138 | r = yield self.pool_manager.fetch(request, raise_error=False) 139 | 140 | if _preload_content: 141 | 142 | r = RESTResponse(r) 143 | 144 | # log response body 145 | logger.debug("response body: %s", r.data) 146 | 147 | if not 200 <= r.status <= 299: 148 | raise ApiException(http_resp=r) 149 | 150 | raise tornado.gen.Return(r) 151 | 152 | @tornado.gen.coroutine 153 | def GET(self, url, headers=None, query_params=None, _preload_content=True, 154 | _request_timeout=None): 155 | result = yield self.request("GET", url, 156 | headers=headers, 157 | _preload_content=_preload_content, 158 | _request_timeout=_request_timeout, 159 | query_params=query_params) 160 | raise tornado.gen.Return(result) 161 | 162 | @tornado.gen.coroutine 163 | def HEAD(self, url, headers=None, query_params=None, _preload_content=True, 164 | _request_timeout=None): 165 | result = yield self.request("HEAD", url, 166 | headers=headers, 167 | _preload_content=_preload_content, 168 | _request_timeout=_request_timeout, 169 | query_params=query_params) 170 | raise tornado.gen.Return(result) 171 | 172 | @tornado.gen.coroutine 173 | def OPTIONS(self, url, headers=None, query_params=None, post_params=None, 174 | body=None, _preload_content=True, _request_timeout=None): 175 | result = yield self.request("OPTIONS", url, 176 | headers=headers, 177 | query_params=query_params, 178 | post_params=post_params, 179 | _preload_content=_preload_content, 180 | _request_timeout=_request_timeout, 181 | body=body) 182 | raise tornado.gen.Return(result) 183 | 184 | @tornado.gen.coroutine 185 | def DELETE(self, url, headers=None, query_params=None, body=None, 186 | _preload_content=True, _request_timeout=None): 187 | result = yield self.request("DELETE", url, 188 | headers=headers, 189 | query_params=query_params, 190 | _preload_content=_preload_content, 191 | _request_timeout=_request_timeout, 192 | body=body) 193 | raise tornado.gen.Return(result) 194 | 195 | @tornado.gen.coroutine 196 | def POST(self, url, headers=None, query_params=None, post_params=None, 197 | body=None, _preload_content=True, _request_timeout=None): 198 | result = yield self.request("POST", url, 199 | headers=headers, 200 | query_params=query_params, 201 | post_params=post_params, 202 | _preload_content=_preload_content, 203 | _request_timeout=_request_timeout, 204 | body=body) 205 | raise tornado.gen.Return(result) 206 | 207 | @tornado.gen.coroutine 208 | def PUT(self, url, headers=None, query_params=None, post_params=None, 209 | body=None, _preload_content=True, _request_timeout=None): 210 | result = yield self.request("PUT", url, 211 | headers=headers, 212 | query_params=query_params, 213 | post_params=post_params, 214 | _preload_content=_preload_content, 215 | _request_timeout=_request_timeout, 216 | body=body) 217 | raise tornado.gen.Return(result) 218 | 219 | @tornado.gen.coroutine 220 | def PATCH(self, url, headers=None, query_params=None, post_params=None, 221 | body=None, _preload_content=True, _request_timeout=None): 222 | result = yield self.request("PATCH", url, 223 | headers=headers, 224 | query_params=query_params, 225 | post_params=post_params, 226 | _preload_content=_preload_content, 227 | _request_timeout=_request_timeout, 228 | body=body) 229 | raise tornado.gen.Return(result) 230 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/39/39ccaca79c80a925989378c2cfc479e6fc04767b.svn-base: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | from __future__ import absolute_import 6 | 7 | import unittest 8 | 9 | import {{packageName}} 10 | from {{apiPackage}}.{{classVarName}} import {{classname}} # noqa: E501 11 | from {{packageName}}.rest import ApiException 12 | 13 | 14 | class {{#operations}}Test{{classname}}(unittest.TestCase): 15 | """{{classname}} unit test stubs""" 16 | 17 | def setUp(self): 18 | self.api = {{apiPackage}}.{{classVarName}}.{{classname}}() # noqa: E501 19 | 20 | def tearDown(self): 21 | pass 22 | 23 | {{#operation}} 24 | def test_{{operationId}}(self): 25 | """Test case for {{{operationId}}} 26 | 27 | {{#summary}} 28 | {{{summary}}} # noqa: E501 29 | {{/summary}} 30 | """ 31 | pass 32 | 33 | {{/operation}} 34 | {{/operations}} 35 | 36 | if __name__ == '__main__': 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/3c/3c722373f8d283d1868b930574cb613d930cba52.svn-base: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | {{>partial_header}} 5 | 6 | from __future__ import absolute_import 7 | 8 | # import models into model package 9 | {{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}} 10 | {{/models}} 11 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/3d/3dbcb7d62227b54eae49fc82a65a12e9965c5e64.svn-base: -------------------------------------------------------------------------------- 1 | # ref: https://docs.travis-ci.com/user/languages/python 2 | language: python 3 | python: 4 | - "2.7" 5 | - "3.2" 6 | - "3.3" 7 | - "3.4" 8 | - "3.5" 9 | #- "3.5-dev" # 3.5 development branch 10 | #- "nightly" # points to the latest development branch e.g. 3.6-dev 11 | # command to install dependencies 12 | install: "pip install -r requirements.txt" 13 | # command to run tests 14 | script: nosetests 15 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/44/444eae2c62f2edda2a8595d7d28d920df1f395be.svn-base: -------------------------------------------------------------------------------- 1 | """ 2 | {{#appName}} 3 | {{{appName}}} 4 | {{/appName}} 5 | 6 | {{#appDescription}} 7 | {{{appDescription}}} # noqa: E501 8 | {{/appDescription}} 9 | 10 | {{#version}} 11 | OpenAPI spec version: {{{version}}} 12 | {{/version}} 13 | {{#infoEmail}} 14 | Contact: {{{infoEmail}}} 15 | {{/infoEmail}} 16 | Generated by: https://openapi-generator.tech 17 | """ 18 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/64/644cc5eef2cf5ebdaf661549afefdc4c08e505bd.svn-base: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | import pprint 6 | import re # noqa: F401 7 | 8 | import six 9 | 10 | 11 | {{#models}} 12 | {{#model}} 13 | class {{classname}}(object): 14 | """NOTE: This class is auto generated by OpenAPI Generator. 15 | Ref: https://openapi-generator.tech 16 | 17 | Do not edit the class manually. 18 | """{{#allowableValues}} 19 | 20 | """ 21 | allowed enum values 22 | """ 23 | {{#enumVars}} 24 | {{name}} = {{{value}}}{{^-last}} 25 | {{/-last}} 26 | {{/enumVars}}{{/allowableValues}} 27 | 28 | """ 29 | Attributes: 30 | openapi_types (dict): The key is attribute name 31 | and the value is attribute type. 32 | attribute_map (dict): The key is attribute name 33 | and the value is json key in definition. 34 | """ 35 | openapi_types = { 36 | {{#vars}} 37 | '{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}} 38 | {{/vars}} 39 | } 40 | 41 | attribute_map = { 42 | {{#vars}} 43 | '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} 44 | {{/vars}} 45 | } 46 | {{#discriminator}} 47 | 48 | discriminator_value_class_map = { 49 | {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}}, 50 | {{/-last}}{{/children}} 51 | } 52 | {{/discriminator}} 53 | 54 | def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 55 | """{{classname}} - a model defined in OpenAPI""" # noqa: E501 56 | {{#vars}}{{#-first}} 57 | {{/-first}} 58 | self._{{name}} = None 59 | {{/vars}} 60 | self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} 61 | {{#vars}}{{#-first}} 62 | {{/-first}} 63 | {{#required}} 64 | self.{{name}} = {{name}} 65 | {{/required}} 66 | {{^required}} 67 | {{#isNullable}} 68 | self.{{name}} = {{name}} 69 | {{/isNullable}} 70 | {{^isNullable}} 71 | if {{name}} is not None: 72 | self.{{name}} = {{name}} 73 | {{/isNullable}} 74 | {{/required}} 75 | {{/vars}} 76 | 77 | {{#vars}} 78 | @property 79 | def {{name}}(self): 80 | """Gets the {{name}} of this {{classname}}. # noqa: E501 81 | 82 | {{#description}} 83 | {{{description}}} # noqa: E501 84 | {{/description}} 85 | 86 | :return: The {{name}} of this {{classname}}. # noqa: E501 87 | :rtype: {{dataType}} 88 | """ 89 | return self._{{name}} 90 | 91 | @{{name}}.setter 92 | def {{name}}(self, {{name}}): 93 | """Sets the {{name}} of this {{classname}}. 94 | 95 | {{#description}} 96 | {{{description}}} # noqa: E501 97 | {{/description}} 98 | 99 | :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 100 | :type: {{dataType}} 101 | """ 102 | {{^isNullable}} 103 | {{#required}} 104 | if {{name}} is None: 105 | raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 106 | {{/required}} 107 | {{/isNullable}} 108 | {{#isEnum}} 109 | {{#isContainer}} 110 | allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 111 | {{#isListContainer}} 112 | if not set({{{name}}}).issubset(set(allowed_values)): 113 | raise ValueError( 114 | "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 115 | .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 116 | ", ".join(map(str, allowed_values))) 117 | ) 118 | {{/isListContainer}} 119 | {{#isMapContainer}} 120 | if not set({{{name}}}.keys()).issubset(set(allowed_values)): 121 | raise ValueError( 122 | "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 123 | .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 124 | ", ".join(map(str, allowed_values))) 125 | ) 126 | {{/isMapContainer}} 127 | {{/isContainer}} 128 | {{^isContainer}} 129 | allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 130 | if {{{name}}} not in allowed_values: 131 | raise ValueError( 132 | "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 133 | .format({{{name}}}, allowed_values) 134 | ) 135 | {{/isContainer}} 136 | {{/isEnum}} 137 | {{^isEnum}} 138 | {{#hasValidation}} 139 | {{#maxLength}} 140 | if {{name}} is not None and len({{name}}) > {{maxLength}}: 141 | raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 142 | {{/maxLength}} 143 | {{#minLength}} 144 | if {{name}} is not None and len({{name}}) < {{minLength}}: 145 | raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 146 | {{/minLength}} 147 | {{#maximum}} 148 | if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 149 | raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 150 | {{/maximum}} 151 | {{#minimum}} 152 | if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 153 | raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 154 | {{/minimum}} 155 | {{#pattern}} 156 | if {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 157 | raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 158 | {{/pattern}} 159 | {{#maxItems}} 160 | if {{name}} is not None and len({{name}}) > {{maxItems}}: 161 | raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 162 | {{/maxItems}} 163 | {{#minItems}} 164 | if {{name}} is not None and len({{name}}) < {{minItems}}: 165 | raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 166 | {{/minItems}} 167 | {{/hasValidation}} 168 | {{/isEnum}} 169 | 170 | self._{{name}} = {{name}} 171 | 172 | {{/vars}} 173 | {{#discriminator}} 174 | def get_real_child_model(self, data): 175 | """Returns the real base class specified by the discriminator""" 176 | discriminator_key = self.attribute_map[self.discriminator] 177 | discriminator_value = data[discriminator_key] 178 | return self.discriminator_value_class_map.get(discriminator_value) 179 | 180 | {{/discriminator}} 181 | def to_dict(self): 182 | """Returns the model properties as a dict""" 183 | result = {} 184 | 185 | for attr, _ in six.iteritems(self.openapi_types): 186 | value = getattr(self, attr) 187 | if isinstance(value, list): 188 | result[attr] = list(map( 189 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 190 | value 191 | )) 192 | elif hasattr(value, "to_dict"): 193 | result[attr] = value.to_dict() 194 | elif isinstance(value, dict): 195 | result[attr] = dict(map( 196 | lambda item: (item[0], item[1].to_dict()) 197 | if hasattr(item[1], "to_dict") else item, 198 | value.items() 199 | )) 200 | else: 201 | result[attr] = value 202 | 203 | return result 204 | 205 | def to_str(self): 206 | """Returns the string representation of the model""" 207 | return pprint.pformat(self.to_dict()) 208 | 209 | def __repr__(self): 210 | """For `print` and `pprint`""" 211 | return self.to_str() 212 | 213 | def __eq__(self, other): 214 | """Returns true if both objects are equal""" 215 | if not isinstance(other, {{classname}}): 216 | return False 217 | 218 | return self.__dict__ == other.__dict__ 219 | 220 | def __ne__(self, other): 221 | """Returns true if both objects are not equal""" 222 | return not self == other 223 | {{/model}} 224 | {{/models}} 225 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/66/6688bb6debacfb5d9b2430e5caf5ef73ea265a46.svn-base: -------------------------------------------------------------------------------- 1 | {{^asyncio}} 2 | coverage>=4.0.3 3 | nose>=1.3.7 4 | {{/asyncio}} 5 | {{#asyncio}} 6 | pytest>=3.6.0 7 | pytest-cov>=2.6.1 8 | {{/asyncio}} 9 | pluggy>=0.3.1 10 | py>=1.4.31 11 | randomize>=0.13 12 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/7c/7c80061b88ec974c0ff6cbe63d96d9194d9c0c57.svn-base: -------------------------------------------------------------------------------- 1 | ```python 2 | from __future__ import print_function 3 | import time 4 | import {{{packageName}}} 5 | from {{{packageName}}}.rest import ApiException 6 | from pprint import pprint 7 | {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} 8 | {{> python_doc_auth_partial}} 9 | # create an instance of the API class 10 | api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) 11 | {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} 12 | {{/allParams}} 13 | 14 | try: 15 | {{#summary}} # {{{.}}} 16 | {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} 17 | pprint(api_response){{/returnType}} 18 | except ApiException as e: 19 | print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) 20 | {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} 21 | ``` 22 | 23 | ## Documentation for API Endpoints 24 | 25 | All URIs are relative to *{{basePath}}* 26 | 27 | Class | Method | HTTP request | Description 28 | ------------ | ------------- | ------------- | ------------- 29 | {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} 30 | {{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} 31 | 32 | ## Documentation For Models 33 | 34 | {{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) 35 | {{/model}}{{/models}} 36 | 37 | ## Documentation For Authorization 38 | 39 | {{^authMethods}} 40 | All endpoints do not require authorization. 41 | {{/authMethods}} 42 | {{#authMethods}} 43 | {{#last}} Authentication schemes defined for the API:{{/last}} 44 | ## {{{name}}} 45 | 46 | {{#isApiKey}} 47 | - **Type**: API key 48 | - **API key parameter name**: {{{keyParamName}}} 49 | - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} 50 | {{/isApiKey}} 51 | {{#isBasic}} 52 | {{^isBasicBearer}} 53 | - **Type**: HTTP basic authentication 54 | {{/isBasicBearer}} 55 | {{#isBasicBearer}} 56 | - **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} 57 | {{/isBasicBearer}} 58 | {{/isBasic}} 59 | {{#isOAuth}} 60 | - **Type**: OAuth 61 | - **Flow**: {{{flow}}} 62 | - **Authorization URL**: {{{authorizationUrl}}} 63 | - **Scopes**: {{^scopes}}N/A{{/scopes}} 64 | {{#scopes}} - **{{{scope}}}**: {{{description}}} 65 | {{/scopes}} 66 | {{/isOAuth}} 67 | 68 | {{/authMethods}} 69 | 70 | ## Author 71 | 72 | {{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} 73 | {{/hasMore}}{{/apis}}{{/apiInfo}} 74 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/87/87b870d25d2c7c8b11f53bf6626fa63ee323b525.svn-base: -------------------------------------------------------------------------------- 1 | # {{{projectName}}} 2 | {{#appDescription}} 3 | {{{appDescription}}} 4 | {{/appDescription}} 5 | 6 | This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: 7 | 8 | - API version: {{appVersion}} 9 | - Package version: {{packageVersion}} 10 | {{^hideGenerationTimestamp}} 11 | - Build date: {{generatedDate}} 12 | {{/hideGenerationTimestamp}} 13 | - Build package: {{generatorClass}} 14 | {{#infoUrl}} 15 | For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) 16 | {{/infoUrl}} 17 | 18 | ## Requirements. 19 | 20 | Python 2.7 and 3.4+ 21 | 22 | ## Installation & Usage 23 | ### pip install 24 | 25 | If the python package is hosted on Github, you can install directly from Github 26 | 27 | ```sh 28 | pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git 29 | ``` 30 | (you may need to run `pip` with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`) 31 | 32 | Then import the package: 33 | ```python 34 | import {{{packageName}}} 35 | ``` 36 | 37 | ### Setuptools 38 | 39 | Install via [Setuptools](http://pypi.python.org/pypi/setuptools). 40 | 41 | ```sh 42 | python setup.py install --user 43 | ``` 44 | (or `sudo python setup.py install` to install the package for all users) 45 | 46 | Then import the package: 47 | ```python 48 | import {{{packageName}}} 49 | ``` 50 | 51 | ## Getting Started 52 | 53 | Please follow the [installation procedure](#installation--usage) and then run the following: 54 | 55 | {{> common_README }} 56 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/a0/a0e98ebbdda8c89351e676f19cc7cdb35d3df25d.svn-base: -------------------------------------------------------------------------------- 1 | ```python 2 | from __future__ import print_function 3 | import time 4 | import {{{packageName}}} 5 | from {{{packageName}}}.rest import ApiException 6 | from pprint import pprint 7 | {{> python_doc_auth_partial}} 8 | {{#hasAuthMethods}} 9 | # create an instance of the API class 10 | api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) 11 | {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} 12 | {{/allParams}} 13 | {{/hasAuthMethods}} 14 | {{^hasAuthMethods}} 15 | # create an instance of the API class 16 | api_instance = {{{packageName}}}.{{{classname}}}() 17 | {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} 18 | {{/allParams}} 19 | {{/hasAuthMethods}} 20 | 21 | try: 22 | {{#summary}} # {{{.}}} 23 | {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} 24 | pprint(api_response){{/returnType}} 25 | except ApiException as e: 26 | print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) 27 | ``` 28 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/a2/a222aaf5e2fc5faf5dc972c903c8fee690e025e8.svn-base: -------------------------------------------------------------------------------- 1 | {{#hasAuthMethods}} 2 | {{#authMethods}} 3 | configuration = {{{packageName}}}.Configuration() 4 | {{#isBasic}} 5 | {{^isBasicBearer}} 6 | # Configure HTTP basic authorization: {{{name}}} 7 | configuration.username = 'YOUR_USERNAME' 8 | configuration.password = 'YOUR_PASSWORD' 9 | {{/isBasicBearer}} 10 | {{#isBasicBearer}} 11 | # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} 12 | configuration.access_token = 'YOUR_BEARER_TOKEN' 13 | {{/isBasicBearer}} 14 | {{/isBasic}} 15 | {{#isApiKey}} 16 | # Configure API key authorization: {{{name}}} 17 | configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' 18 | # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed 19 | # configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer' 20 | {{/isApiKey}} 21 | {{#isOAuth}} 22 | # Configure OAuth2 access token for authorization: {{{name}}} 23 | configuration.access_token = 'YOUR_ACCESS_TOKEN' 24 | {{/isOAuth}} 25 | {{/authMethods}} 26 | {{/hasAuthMethods}} 27 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/ac/ac90754da11973e732a6c00968d60dfad619f64f.svn-base: -------------------------------------------------------------------------------- 1 | {{#models}}{{#model}}# {{classname}} 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | {{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} 7 | {{/vars}} 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | {{/model}}{{/models}} 12 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/ae/aedf29ef75f86b9c04518157f282d7c7990b66f4.svn-base: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | 5 | {{>partial_header}} 6 | 7 | from __future__ import absolute_import 8 | 9 | __version__ = "{{packageVersion}}" 10 | 11 | # import apis into sdk package 12 | {{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} 13 | {{/apis}}{{/apiInfo}} 14 | # import ApiClient 15 | from {{packageName}}.api_client import ApiClient 16 | from {{packageName}}.configuration import Configuration 17 | from {{packageName}}.exceptions import OpenApiException 18 | from {{packageName}}.exceptions import ApiTypeError 19 | from {{packageName}}.exceptions import ApiValueError 20 | from {{packageName}}.exceptions import ApiKeyError 21 | from {{packageName}}.exceptions import ApiException 22 | # import models into sdk package 23 | {{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}} 24 | {{/model}}{{/models}} 25 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/bb/bbc24d7155c02c1875a8317fba7b9d048c9b35be.svn-base: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ 3 | # 4 | # Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" 5 | 6 | git_user_id=$1 7 | git_repo_id=$2 8 | release_note=$3 9 | 10 | if [ "$git_user_id" = "" ]; then 11 | git_user_id="{{{gitUserId}}}" 12 | echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" 13 | fi 14 | 15 | if [ "$git_repo_id" = "" ]; then 16 | git_repo_id="{{{gitRepoId}}}" 17 | echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" 18 | fi 19 | 20 | if [ "$release_note" = "" ]; then 21 | release_note="{{{releaseNote}}}" 22 | echo "[INFO] No command line input provided. Set \$release_note to $release_note" 23 | fi 24 | 25 | # Initialize the local directory as a Git repository 26 | git init 27 | 28 | # Adds the files in the local repository and stages them for commit. 29 | git add . 30 | 31 | # Commits the tracked changes and prepares them to be pushed to a remote repository. 32 | git commit -m "$release_note" 33 | 34 | # Sets the new remote 35 | git_remote=`git remote` 36 | if [ "$git_remote" = "" ]; then # git remote not defined 37 | 38 | if [ "$GIT_TOKEN" = "" ]; then 39 | echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." 40 | git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git 41 | else 42 | git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git 43 | fi 44 | 45 | fi 46 | 47 | git pull origin master 48 | 49 | # Pushes (Forces) the changes in the local repository up to the remote repository 50 | echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" 51 | git push origin master 2>&1 | grep -v 'To https' 52 | 53 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/c3/c3bc189fb655678f52c27e95f97b79e067b818c1.svn-base: -------------------------------------------------------------------------------- 1 | # {{{projectName}}} 2 | {{#appDescription}} 3 | {{{appDescription}}} 4 | {{/appDescription}} 5 | 6 | The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: 7 | 8 | - API version: {{appVersion}} 9 | - Package version: {{packageVersion}} 10 | {{^hideGenerationTimestamp}} 11 | - Build date: {{generatedDate}} 12 | {{/hideGenerationTimestamp}} 13 | - Build package: {{generatorClass}} 14 | {{#infoUrl}} 15 | For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) 16 | {{/infoUrl}} 17 | 18 | ## Requirements. 19 | 20 | Python 2.7 and 3.4+ 21 | 22 | ## Installation & Usage 23 | 24 | This python library package is generated without supporting files like setup.py or requirements files 25 | 26 | To be able to use it, you will need these dependencies in your own package that uses this library: 27 | 28 | * urllib3 >= 1.15 29 | * six >= 1.10 30 | * certifi 31 | * python-dateutil 32 | {{#asyncio}} 33 | * aiohttp 34 | {{/asyncio}} 35 | {{#tornado}} 36 | * tornado>=4.2,<5 37 | {{/tornado}} 38 | 39 | ## Getting Started 40 | 41 | In your own code, to use this library to connect and interact with {{{projectName}}}, 42 | you can run the following: 43 | 44 | {{> common_README }} 45 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/da/da39a3ee5e6b4b0d3255bfef95601890afd80709.svn-base: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b3nab/instagram-api-toolkit/b68a52e1a3cfa4f1b67850d13f502e82b5743304/templates/python/.svn/pristine/da/da39a3ee5e6b4b0d3255bfef95601890afd80709.svn-base -------------------------------------------------------------------------------- /templates/python/.svn/pristine/ed/ed083d2a05780b50c2ed0d04bce680cd910f6e0d.svn-base: -------------------------------------------------------------------------------- 1 | certifi >= 14.05.14 2 | six >= 1.10 3 | python_dateutil >= 2.5.3 4 | setuptools >= 21.0.0 5 | urllib3 >= 1.15.1 6 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/f3/f3f6c7f3eda230aa494c94f03959162143250ff3.svn-base: -------------------------------------------------------------------------------- 1 | [tox] 2 | {{^asyncio}} 3 | envlist = py27, py3 4 | {{/asyncio}} 5 | {{#asyncio}} 6 | envlist = py3 7 | {{/asyncio}} 8 | 9 | [testenv] 10 | deps=-r{toxinidir}/requirements.txt 11 | -r{toxinidir}/test-requirements.txt 12 | 13 | commands= 14 | {{^asyncio}} 15 | nosetests \ 16 | [] 17 | {{/asyncio}} 18 | {{#asyncio}} 19 | pytest -v --cov petstore_api 20 | {{/asyncio}} 21 | -------------------------------------------------------------------------------- /templates/python/.svn/pristine/fc/fcfbd803ba2659232ce666fb6d5a172ebde2fe12.svn-base: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | import six 6 | 7 | 8 | class OpenApiException(Exception): 9 | """The base exception class for all OpenAPIExceptions""" 10 | 11 | 12 | class ApiTypeError(OpenApiException, TypeError): 13 | def __init__(self, msg, path_to_item=None, valid_classes=None, 14 | key_type=None): 15 | """ Raises an exception for TypeErrors 16 | 17 | Args: 18 | msg (str): the exception message 19 | 20 | Keyword Args: 21 | path_to_item (list): a list of keys an indices to get to the 22 | current_item 23 | None if unset 24 | valid_classes (tuple): the primitive classes that current item 25 | should be an instance of 26 | None if unset 27 | key_type (bool): False if our value is a value in a dict 28 | True if it is a key in a dict 29 | False if our item is an item in a list 30 | None if unset 31 | """ 32 | self.path_to_item = path_to_item 33 | self.valid_classes = valid_classes 34 | self.key_type = key_type 35 | full_msg = msg 36 | if path_to_item: 37 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 38 | super(ApiTypeError, self).__init__(full_msg) 39 | 40 | 41 | class ApiValueError(OpenApiException, ValueError): 42 | def __init__(self, msg, path_to_item=None): 43 | """ 44 | Args: 45 | msg (str): the exception message 46 | 47 | Keyword Args: 48 | path_to_item (list) the path to the exception in the 49 | received_data dict. None if unset 50 | """ 51 | 52 | self.path_to_item = path_to_item 53 | full_msg = msg 54 | if path_to_item: 55 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 56 | super(ApiValueError, self).__init__(full_msg) 57 | 58 | 59 | class ApiKeyError(OpenApiException, KeyError): 60 | def __init__(self, msg, path_to_item=None): 61 | """ 62 | Args: 63 | msg (str): the exception message 64 | 65 | Keyword Args: 66 | path_to_item (None/list) the path to the exception in the 67 | received_data dict 68 | """ 69 | self.path_to_item = path_to_item 70 | full_msg = msg 71 | if path_to_item: 72 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 73 | super(ApiKeyError, self).__init__(full_msg) 74 | 75 | 76 | class ApiException(OpenApiException): 77 | 78 | def __init__(self, status=None, reason=None, http_resp=None): 79 | if http_resp: 80 | self.status = http_resp.status 81 | self.reason = http_resp.reason 82 | self.body = http_resp.data 83 | self.headers = http_resp.getheaders() 84 | else: 85 | self.status = status 86 | self.reason = reason 87 | self.body = None 88 | self.headers = None 89 | 90 | def __str__(self): 91 | """Custom error messages for exception""" 92 | error_message = "({0})\n"\ 93 | "Reason: {1}\n".format(self.status, self.reason) 94 | if self.headers: 95 | error_message += "HTTP response headers: {0}\n".format( 96 | self.headers) 97 | 98 | if self.body: 99 | error_message += "HTTP response body: {0}\n".format(self.body) 100 | 101 | return error_message 102 | 103 | 104 | def render_path(path_to_item): 105 | """Returns a string representation of a path""" 106 | result = "" 107 | for pth in path_to_item: 108 | if isinstance(pth, six.integer_types): 109 | result += "[{0}]".format(pth) 110 | else: 111 | result += "['{0}']".format(pth) 112 | return result 113 | -------------------------------------------------------------------------------- /templates/python/.svn/wc.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b3nab/instagram-api-toolkit/b68a52e1a3cfa4f1b67850d13f502e82b5743304/templates/python/.svn/wc.db -------------------------------------------------------------------------------- /templates/python/.svn/wc.db-journal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b3nab/instagram-api-toolkit/b68a52e1a3cfa4f1b67850d13f502e82b5743304/templates/python/.svn/wc.db-journal -------------------------------------------------------------------------------- /templates/python/README.mustache: -------------------------------------------------------------------------------- 1 | # {{{projectName}}} 2 | {{#appDescription}} 3 | {{{appDescription}}} 4 | {{/appDescription}} 5 | 6 | This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: 7 | 8 | - API version: {{appVersion}} 9 | - Package version: {{packageVersion}} 10 | {{^hideGenerationTimestamp}} 11 | - Build date: {{generatedDate}} 12 | {{/hideGenerationTimestamp}} 13 | - Build package: {{generatorClass}} 14 | {{#infoUrl}} 15 | For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) 16 | {{/infoUrl}} 17 | 18 | ## Requirements. 19 | 20 | Python 2.7 and 3.4+ 21 | 22 | ## Installation & Usage 23 | ### pip install 24 | 25 | If the python package is hosted on Github, you can install directly from Github 26 | 27 | ```sh 28 | pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git 29 | ``` 30 | (you may need to run `pip` with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`) 31 | 32 | Then import the package: 33 | ```python 34 | import {{{packageName}}} 35 | ``` 36 | 37 | ### Setuptools 38 | 39 | Install via [Setuptools](http://pypi.python.org/pypi/setuptools). 40 | 41 | ```sh 42 | python setup.py install --user 43 | ``` 44 | (or `sudo python setup.py install` to install the package for all users) 45 | 46 | Then import the package: 47 | ```python 48 | import {{{packageName}}} 49 | ``` 50 | 51 | ## Getting Started 52 | 53 | Please follow the [installation procedure](#installation--usage) and then run the following: 54 | 55 | {{> common_README }} 56 | -------------------------------------------------------------------------------- /templates/python/README_onlypackage.mustache: -------------------------------------------------------------------------------- 1 | # {{{projectName}}} 2 | {{#appDescription}} 3 | {{{appDescription}}} 4 | {{/appDescription}} 5 | 6 | The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: 7 | 8 | - API version: {{appVersion}} 9 | - Package version: {{packageVersion}} 10 | {{^hideGenerationTimestamp}} 11 | - Build date: {{generatedDate}} 12 | {{/hideGenerationTimestamp}} 13 | - Build package: {{generatorClass}} 14 | {{#infoUrl}} 15 | For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) 16 | {{/infoUrl}} 17 | 18 | ## Requirements. 19 | 20 | Python 2.7 and 3.4+ 21 | 22 | ## Installation & Usage 23 | 24 | This python library package is generated without supporting files like setup.py or requirements files 25 | 26 | To be able to use it, you will need these dependencies in your own package that uses this library: 27 | 28 | * urllib3 >= 1.15 29 | * six >= 1.10 30 | * certifi 31 | * python-dateutil 32 | {{#asyncio}} 33 | * aiohttp 34 | {{/asyncio}} 35 | {{#tornado}} 36 | * tornado>=4.2,<5 37 | {{/tornado}} 38 | 39 | ## Getting Started 40 | 41 | In your own code, to use this library to connect and interact with {{{projectName}}}, 42 | you can run the following: 43 | 44 | {{> common_README }} 45 | -------------------------------------------------------------------------------- /templates/python/__init__api.mustache: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | # flake8: noqa 4 | 5 | # import apis into api package 6 | {{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} 7 | {{/apis}}{{/apiInfo}} -------------------------------------------------------------------------------- /templates/python/__init__model.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | {{>partial_header}} 5 | 6 | from __future__ import absolute_import 7 | 8 | # import models into model package 9 | {{#models}}{{#model}}from {{packageName}}.models.{{classVarName}} import {{classname}} 10 | {{/model}}{{/models}} -------------------------------------------------------------------------------- /templates/python/__init__package.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | 5 | {{>partial_header}} 6 | 7 | from __future__ import absolute_import 8 | 9 | __version__ = "{{packageVersion}}" 10 | 11 | # import apis into sdk package 12 | {{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classVarName}} import {{classname}} 13 | {{/apis}}{{/apiInfo}} 14 | # import ApiClient 15 | from {{packageName}}.api_client import ApiClient 16 | from {{packageName}}.configuration import Configuration 17 | from {{packageName}}.exceptions import OpenApiException 18 | from {{packageName}}.exceptions import ApiTypeError 19 | from {{packageName}}.exceptions import ApiValueError 20 | from {{packageName}}.exceptions import ApiKeyError 21 | from {{packageName}}.exceptions import ApiException 22 | # import models into model package 23 | {{#models}}{{#model}}from {{packageName}}.models.{{classVarName}} import {{classname}} 24 | {{/model}}{{/models}} 25 | -------------------------------------------------------------------------------- /templates/python/__init__test.mustache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/b3nab/instagram-api-toolkit/b68a52e1a3cfa4f1b67850d13f502e82b5743304/templates/python/__init__test.mustache -------------------------------------------------------------------------------- /templates/python/api_doc.mustache: -------------------------------------------------------------------------------- 1 | # {{packageName}}.{{classname}}{{#description}} 2 | {{description}}{{/description}} 3 | 4 | All URIs are relative to *{{basePath}}* 5 | 6 | Method | HTTP request | Description 7 | ------------- | ------------- | ------------- 8 | {{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} 9 | {{/operation}}{{/operations}} 10 | 11 | {{#operations}} 12 | {{#operation}} 13 | # **{{{operationId}}}** 14 | > {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) 15 | 16 | {{{summary}}}{{#notes}} 17 | 18 | {{{notes}}}{{/notes}} 19 | 20 | ### Example 21 | 22 | {{#hasAuthMethods}} 23 | {{#authMethods}} 24 | {{#isBasic}} 25 | {{^isBasicBearer}} 26 | * Basic Authentication ({{name}}): 27 | {{/isBasicBearer}} 28 | {{#isBasicBearer}} 29 | * Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} Authentication ({{name}}): 30 | {{/isBasicBearer}} 31 | {{/isBasic}} 32 | {{#isApiKey}} 33 | * Api Key Authentication ({{name}}): 34 | {{/isApiKey }} 35 | {{#isOAuth}} 36 | * OAuth Authentication ({{name}}): 37 | {{/isOAuth }} 38 | {{> api_doc_example }} 39 | {{/authMethods}} 40 | {{/hasAuthMethods}} 41 | {{^hasAuthMethods}} 42 | {{> api_doc_example }} 43 | {{/hasAuthMethods}} 44 | ### Parameters 45 | {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} 46 | Name | Type | Description | Notes 47 | ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} 48 | {{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} 49 | {{/allParams}} 50 | 51 | ### Return type 52 | 53 | {{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} 54 | 55 | ### Authorization 56 | 57 | {{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} 58 | 59 | ### HTTP request headers 60 | 61 | - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} 62 | - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} 63 | 64 | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) 65 | 66 | {{/operation}} 67 | {{/operations}} 68 | -------------------------------------------------------------------------------- /templates/python/api_doc_example.mustache: -------------------------------------------------------------------------------- 1 | ```python 2 | from __future__ import print_function 3 | import time 4 | import {{{packageName}}} 5 | from {{{packageName}}}.rest import ApiException 6 | from pprint import pprint 7 | {{> python_doc_auth_partial}} 8 | {{#hasAuthMethods}} 9 | # create an instance of the API class 10 | api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) 11 | {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} 12 | {{/allParams}} 13 | {{/hasAuthMethods}} 14 | {{^hasAuthMethods}} 15 | # create an instance of the API class 16 | api_instance = {{{packageName}}}.{{{classname}}}() 17 | {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} 18 | {{/allParams}} 19 | {{/hasAuthMethods}} 20 | 21 | try: 22 | {{#summary}} # {{{.}}} 23 | {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} 24 | pprint(api_response){{/returnType}} 25 | except ApiException as e: 26 | print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) 27 | ``` 28 | -------------------------------------------------------------------------------- /templates/python/api_test.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | from __future__ import absolute_import 6 | 7 | import unittest 8 | 9 | import {{packageName}} 10 | from {{apiPackage}}.{{classVarName}} import {{classname}} # noqa: E501 11 | from {{packageName}}.rest import ApiException 12 | 13 | 14 | class {{#operations}}Test{{classname}}(unittest.TestCase): 15 | """{{classname}} unit test stubs""" 16 | 17 | def setUp(self): 18 | self.api = {{apiPackage}}.{{classVarName}}.{{classname}}() # noqa: E501 19 | 20 | def tearDown(self): 21 | pass 22 | 23 | {{#operation}} 24 | def test_{{operationId}}(self): 25 | """Test case for {{{operationId}}} 26 | 27 | {{#summary}} 28 | {{{summary}}} # noqa: E501 29 | {{/summary}} 30 | """ 31 | pass 32 | 33 | {{/operation}} 34 | {{/operations}} 35 | 36 | if __name__ == '__main__': 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /templates/python/common_README.mustache: -------------------------------------------------------------------------------- 1 | ```python 2 | from __future__ import print_function 3 | import time 4 | import {{{packageName}}} 5 | from {{{packageName}}}.rest import ApiException 6 | from pprint import pprint 7 | {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} 8 | {{> python_doc_auth_partial}} 9 | # create an instance of the API class 10 | api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) 11 | {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} 12 | {{/allParams}} 13 | 14 | try: 15 | {{#summary}} # {{{.}}} 16 | {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} 17 | pprint(api_response){{/returnType}} 18 | except ApiException as e: 19 | print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) 20 | {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} 21 | ``` 22 | 23 | ## Documentation for API Endpoints 24 | 25 | All URIs are relative to *{{basePath}}* 26 | 27 | Class | Method | HTTP request | Description 28 | ------------ | ------------- | ------------- | ------------- 29 | {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} 30 | {{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} 31 | 32 | ## Documentation For Models 33 | 34 | {{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) 35 | {{/model}}{{/models}} 36 | 37 | ## Documentation For Authorization 38 | 39 | {{^authMethods}} 40 | All endpoints do not require authorization. 41 | {{/authMethods}} 42 | {{#authMethods}} 43 | {{#last}} Authentication schemes defined for the API:{{/last}} 44 | ## {{{name}}} 45 | 46 | {{#isApiKey}} 47 | - **Type**: API key 48 | - **API key parameter name**: {{{keyParamName}}} 49 | - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} 50 | {{/isApiKey}} 51 | {{#isBasic}} 52 | {{^isBasicBearer}} 53 | - **Type**: HTTP basic authentication 54 | {{/isBasicBearer}} 55 | {{#isBasicBearer}} 56 | - **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} 57 | {{/isBasicBearer}} 58 | {{/isBasic}} 59 | {{#isOAuth}} 60 | - **Type**: OAuth 61 | - **Flow**: {{{flow}}} 62 | - **Authorization URL**: {{{authorizationUrl}}} 63 | - **Scopes**: {{^scopes}}N/A{{/scopes}} 64 | {{#scopes}} - **{{{scope}}}**: {{{description}}} 65 | {{/scopes}} 66 | {{/isOAuth}} 67 | 68 | {{/authMethods}} 69 | 70 | ## Author 71 | 72 | {{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} 73 | {{/hasMore}}{{/apis}}{{/apiInfo}} 74 | -------------------------------------------------------------------------------- /templates/python/exceptions.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | import six 6 | 7 | 8 | class OpenApiException(Exception): 9 | """The base exception class for all OpenAPIExceptions""" 10 | 11 | 12 | class ApiTypeError(OpenApiException, TypeError): 13 | def __init__(self, msg, path_to_item=None, valid_classes=None, 14 | key_type=None): 15 | """ Raises an exception for TypeErrors 16 | 17 | Args: 18 | msg (str): the exception message 19 | 20 | Keyword Args: 21 | path_to_item (list): a list of keys an indices to get to the 22 | current_item 23 | None if unset 24 | valid_classes (tuple): the primitive classes that current item 25 | should be an instance of 26 | None if unset 27 | key_type (bool): False if our value is a value in a dict 28 | True if it is a key in a dict 29 | False if our item is an item in a list 30 | None if unset 31 | """ 32 | self.path_to_item = path_to_item 33 | self.valid_classes = valid_classes 34 | self.key_type = key_type 35 | full_msg = msg 36 | if path_to_item: 37 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 38 | super(ApiTypeError, self).__init__(full_msg) 39 | 40 | 41 | class ApiValueError(OpenApiException, ValueError): 42 | def __init__(self, msg, path_to_item=None): 43 | """ 44 | Args: 45 | msg (str): the exception message 46 | 47 | Keyword Args: 48 | path_to_item (list) the path to the exception in the 49 | received_data dict. None if unset 50 | """ 51 | 52 | self.path_to_item = path_to_item 53 | full_msg = msg 54 | if path_to_item: 55 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 56 | super(ApiValueError, self).__init__(full_msg) 57 | 58 | 59 | class ApiKeyError(OpenApiException, KeyError): 60 | def __init__(self, msg, path_to_item=None): 61 | """ 62 | Args: 63 | msg (str): the exception message 64 | 65 | Keyword Args: 66 | path_to_item (None/list) the path to the exception in the 67 | received_data dict 68 | """ 69 | self.path_to_item = path_to_item 70 | full_msg = msg 71 | if path_to_item: 72 | full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 73 | super(ApiKeyError, self).__init__(full_msg) 74 | 75 | 76 | class ApiException(OpenApiException): 77 | 78 | def __init__(self, status=None, reason=None, http_resp=None): 79 | if http_resp: 80 | self.status = http_resp.status 81 | self.reason = http_resp.reason 82 | self.body = http_resp.data 83 | self.headers = http_resp.getheaders() 84 | else: 85 | self.status = status 86 | self.reason = reason 87 | self.body = None 88 | self.headers = None 89 | 90 | def __str__(self): 91 | """Custom error messages for exception""" 92 | error_message = "({0})\n"\ 93 | "Reason: {1}\n".format(self.status, self.reason) 94 | if self.headers: 95 | error_message += "HTTP response headers: {0}\n".format( 96 | self.headers) 97 | 98 | if self.body: 99 | error_message += "HTTP response body: {0}\n".format(self.body) 100 | 101 | return error_message 102 | 103 | 104 | def render_path(path_to_item): 105 | """Returns a string representation of a path""" 106 | result = "" 107 | for pth in path_to_item: 108 | if isinstance(pth, six.integer_types): 109 | result += "[{0}]".format(pth) 110 | else: 111 | result += "['{0}']".format(pth) 112 | return result 113 | -------------------------------------------------------------------------------- /templates/python/git_push.sh.mustache: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ 3 | # 4 | # Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" 5 | 6 | git_user_id=$1 7 | git_repo_id=$2 8 | release_note=$3 9 | 10 | if [ "$git_user_id" = "" ]; then 11 | git_user_id="{{{gitUserId}}}" 12 | echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" 13 | fi 14 | 15 | if [ "$git_repo_id" = "" ]; then 16 | git_repo_id="{{{gitRepoId}}}" 17 | echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" 18 | fi 19 | 20 | if [ "$release_note" = "" ]; then 21 | release_note="{{{releaseNote}}}" 22 | echo "[INFO] No command line input provided. Set \$release_note to $release_note" 23 | fi 24 | 25 | # Initialize the local directory as a Git repository 26 | git init 27 | 28 | # Adds the files in the local repository and stages them for commit. 29 | git add . 30 | 31 | # Commits the tracked changes and prepares them to be pushed to a remote repository. 32 | git commit -m "$release_note" 33 | 34 | # Sets the new remote 35 | git_remote=`git remote` 36 | if [ "$git_remote" = "" ]; then # git remote not defined 37 | 38 | if [ "$GIT_TOKEN" = "" ]; then 39 | echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." 40 | git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git 41 | else 42 | git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git 43 | fi 44 | 45 | fi 46 | 47 | git pull origin master 48 | 49 | # Pushes (Forces) the changes in the local repository up to the remote repository 50 | echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" 51 | git push origin master 2>&1 | grep -v 'To https' 52 | 53 | -------------------------------------------------------------------------------- /templates/python/gitignore.mustache: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | venv/ 48 | .python-version 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | 57 | # Sphinx documentation 58 | docs/_build/ 59 | 60 | # PyBuilder 61 | target/ 62 | 63 | #Ipython Notebook 64 | .ipynb_checkpoints 65 | -------------------------------------------------------------------------------- /templates/python/model.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | import pprint 6 | import re # noqa: F401 7 | 8 | import six 9 | 10 | 11 | {{#models}} 12 | {{#model}} 13 | class {{classname}}(object): 14 | """NOTE: This class is auto generated by OpenAPI Generator. 15 | Ref: https://openapi-generator.tech 16 | 17 | Do not edit the class manually. 18 | """{{#allowableValues}} 19 | 20 | """ 21 | allowed enum values 22 | """ 23 | {{#enumVars}} 24 | {{name}} = {{{value}}}{{^-last}} 25 | {{/-last}} 26 | {{/enumVars}}{{/allowableValues}} 27 | 28 | """ 29 | Attributes: 30 | openapi_types (dict): The key is attribute name 31 | and the value is attribute type. 32 | attribute_map (dict): The key is attribute name 33 | and the value is json key in definition. 34 | """ 35 | openapi_types = { 36 | {{#vars}} 37 | '{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}} 38 | {{/vars}} 39 | } 40 | 41 | attribute_map = { 42 | {{#vars}} 43 | '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} 44 | {{/vars}} 45 | } 46 | {{#discriminator}} 47 | 48 | discriminator_value_class_map = { 49 | {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}}, 50 | {{/-last}}{{/children}} 51 | } 52 | {{/discriminator}} 53 | 54 | def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 55 | """{{classname}} - a model defined in OpenAPI""" # noqa: E501 56 | {{#vars}}{{#-first}} 57 | {{/-first}} 58 | self._{{name}} = None 59 | {{/vars}} 60 | self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} 61 | {{#vars}}{{#-first}} 62 | {{/-first}} 63 | {{#required}} 64 | self.{{name}} = {{name}} 65 | {{/required}} 66 | {{^required}} 67 | {{#isNullable}} 68 | self.{{name}} = {{name}} 69 | {{/isNullable}} 70 | {{^isNullable}} 71 | if {{name}} is not None: 72 | self.{{name}} = {{name}} 73 | {{/isNullable}} 74 | {{/required}} 75 | {{/vars}} 76 | 77 | {{#vars}} 78 | @property 79 | def {{name}}(self): 80 | """Gets the {{name}} of this {{classname}}. # noqa: E501 81 | 82 | {{#description}} 83 | {{{description}}} # noqa: E501 84 | {{/description}} 85 | 86 | :return: The {{name}} of this {{classname}}. # noqa: E501 87 | :rtype: {{dataType}} 88 | """ 89 | return self._{{name}} 90 | 91 | @{{name}}.setter 92 | def {{name}}(self, {{name}}): 93 | """Sets the {{name}} of this {{classname}}. 94 | 95 | {{#description}} 96 | {{{description}}} # noqa: E501 97 | {{/description}} 98 | 99 | :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 100 | :type: {{dataType}} 101 | """ 102 | {{^isNullable}} 103 | {{#required}} 104 | if {{name}} is None: 105 | raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 106 | {{/required}} 107 | {{/isNullable}} 108 | {{#isEnum}} 109 | {{#isContainer}} 110 | allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 111 | {{#isListContainer}} 112 | if not set({{{name}}}).issubset(set(allowed_values)): 113 | raise ValueError( 114 | "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 115 | .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 116 | ", ".join(map(str, allowed_values))) 117 | ) 118 | {{/isListContainer}} 119 | {{#isMapContainer}} 120 | if not set({{{name}}}.keys()).issubset(set(allowed_values)): 121 | raise ValueError( 122 | "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 123 | .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 124 | ", ".join(map(str, allowed_values))) 125 | ) 126 | {{/isMapContainer}} 127 | {{/isContainer}} 128 | {{^isContainer}} 129 | allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 130 | if {{{name}}} not in allowed_values: 131 | raise ValueError( 132 | "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 133 | .format({{{name}}}, allowed_values) 134 | ) 135 | {{/isContainer}} 136 | {{/isEnum}} 137 | {{^isEnum}} 138 | {{#hasValidation}} 139 | {{#maxLength}} 140 | if {{name}} is not None and len({{name}}) > {{maxLength}}: 141 | raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 142 | {{/maxLength}} 143 | {{#minLength}} 144 | if {{name}} is not None and len({{name}}) < {{minLength}}: 145 | raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 146 | {{/minLength}} 147 | {{#maximum}} 148 | if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 149 | raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 150 | {{/maximum}} 151 | {{#minimum}} 152 | if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 153 | raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 154 | {{/minimum}} 155 | {{#pattern}} 156 | if {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 157 | raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 158 | {{/pattern}} 159 | {{#maxItems}} 160 | if {{name}} is not None and len({{name}}) > {{maxItems}}: 161 | raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 162 | {{/maxItems}} 163 | {{#minItems}} 164 | if {{name}} is not None and len({{name}}) < {{minItems}}: 165 | raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 166 | {{/minItems}} 167 | {{/hasValidation}} 168 | {{/isEnum}} 169 | 170 | self._{{name}} = {{name}} 171 | 172 | {{/vars}} 173 | {{#discriminator}} 174 | def get_real_child_model(self, data): 175 | """Returns the real base class specified by the discriminator""" 176 | discriminator_key = self.attribute_map[self.discriminator] 177 | discriminator_value = data[discriminator_key] 178 | return self.discriminator_value_class_map.get(discriminator_value) 179 | 180 | {{/discriminator}} 181 | def to_dict(self): 182 | """Returns the model properties as a dict""" 183 | result = {} 184 | 185 | for attr, _ in six.iteritems(self.openapi_types): 186 | value = getattr(self, attr) 187 | if isinstance(value, list): 188 | result[attr] = list(map( 189 | lambda x: x.to_dict() if hasattr(x, "to_dict") else x, 190 | value 191 | )) 192 | elif hasattr(value, "to_dict"): 193 | result[attr] = value.to_dict() 194 | elif isinstance(value, dict): 195 | result[attr] = dict(map( 196 | lambda item: (item[0], item[1].to_dict()) 197 | if hasattr(item[1], "to_dict") else item, 198 | value.items() 199 | )) 200 | else: 201 | result[attr] = value 202 | 203 | return result 204 | 205 | def to_str(self): 206 | """Returns the string representation of the model""" 207 | return pprint.pformat(self.to_dict()) 208 | 209 | def __repr__(self): 210 | """For `print` and `pprint`""" 211 | return self.to_str() 212 | 213 | def __eq__(self, other): 214 | """Returns true if both objects are equal""" 215 | if not isinstance(other, {{classname}}): 216 | return False 217 | 218 | return self.__dict__ == other.__dict__ 219 | 220 | def __ne__(self, other): 221 | """Returns true if both objects are not equal""" 222 | return not self == other 223 | {{/model}} 224 | {{/models}} 225 | -------------------------------------------------------------------------------- /templates/python/model_doc.mustache: -------------------------------------------------------------------------------- 1 | {{#models}}{{#model}}# {{classname}} 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | {{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} 7 | {{/vars}} 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | {{/model}}{{/models}} 12 | -------------------------------------------------------------------------------- /templates/python/model_test.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | from __future__ import absolute_import 6 | 7 | import unittest 8 | 9 | {{#models}} 10 | {{#model}} 11 | import {{packageName}} 12 | from {{modelPackage}}.{{classFilename}} import {{classname}} # noqa: E501 13 | from {{packageName}}.rest import ApiException 14 | 15 | 16 | class Test{{classname}}(unittest.TestCase): 17 | """{{classname}} unit test stubs""" 18 | 19 | def setUp(self): 20 | pass 21 | 22 | def tearDown(self): 23 | pass 24 | 25 | def test{{classname}}(self): 26 | """Test {{classname}}""" 27 | # FIXME: construct object with mandatory attributes with example values 28 | # model = {{packageName}}.models.{{classFilename}}.{{classname}}() # noqa: E501 29 | pass 30 | 31 | {{/model}} 32 | {{/models}} 33 | 34 | if __name__ == '__main__': 35 | unittest.main() 36 | -------------------------------------------------------------------------------- /templates/python/partial_header.mustache: -------------------------------------------------------------------------------- 1 | """ 2 | {{#appName}} 3 | {{{appName}}} 4 | {{/appName}} 5 | 6 | {{#appDescription}} 7 | {{{appDescription}}} # noqa: E501 8 | {{/appDescription}} 9 | 10 | {{#version}} 11 | OpenAPI spec version: {{{version}}} 12 | {{/version}} 13 | {{#infoEmail}} 14 | Contact: {{{infoEmail}}} 15 | {{/infoEmail}} 16 | GitHub repo: https://github.com/instagrambot/instagram-api-toolkit 17 | """ 18 | -------------------------------------------------------------------------------- /templates/python/python_doc_auth_partial.mustache: -------------------------------------------------------------------------------- 1 | {{#hasAuthMethods}} 2 | {{#authMethods}} 3 | configuration = {{{packageName}}}.Configuration() 4 | {{#isBasic}} 5 | {{^isBasicBearer}} 6 | # Configure HTTP basic authorization: {{{name}}} 7 | configuration.username = 'YOUR_USERNAME' 8 | configuration.password = 'YOUR_PASSWORD' 9 | {{/isBasicBearer}} 10 | {{#isBasicBearer}} 11 | # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} 12 | configuration.access_token = 'YOUR_BEARER_TOKEN' 13 | {{/isBasicBearer}} 14 | {{/isBasic}} 15 | {{#isApiKey}} 16 | # Configure API key authorization: {{{name}}} 17 | configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' 18 | # Uncomment below to setup prefix (e.g. Bearer) for API key, if needed 19 | # configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer' 20 | {{/isApiKey}} 21 | {{#isOAuth}} 22 | # Configure OAuth2 access token for authorization: {{{name}}} 23 | configuration.access_token = 'YOUR_ACCESS_TOKEN' 24 | {{/isOAuth}} 25 | {{/authMethods}} 26 | {{/hasAuthMethods}} 27 | -------------------------------------------------------------------------------- /templates/python/requirements.mustache: -------------------------------------------------------------------------------- 1 | certifi >= 14.05.14 2 | six >= 1.10 3 | python_dateutil >= 2.5.3 4 | setuptools >= 21.0.0 5 | urllib3 >= 1.15.1 6 | -------------------------------------------------------------------------------- /templates/python/rest.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | from __future__ import absolute_import 6 | 7 | import io 8 | import json 9 | import logging 10 | import re 11 | import ssl 12 | 13 | import certifi 14 | # python 2 and python 3 compatibility library 15 | import six 16 | from six.moves.urllib.parse import urlencode 17 | import urllib3 18 | import requests 19 | 20 | from {{packageName}}.exceptions import ApiException, ApiValueError 21 | 22 | 23 | logger = logging.getLogger(__name__) 24 | 25 | 26 | class RESTResponse(io.IOBase): 27 | 28 | def __init__(self, resp): 29 | self.urllib3_response = resp 30 | self.status = resp.status 31 | self.reason = resp.reason 32 | self.data = resp.data 33 | 34 | def getheaders(self): 35 | """Returns a dictionary of the response headers.""" 36 | return self.urllib3_response.getheaders() 37 | 38 | def getheader(self, name, default=None): 39 | """Returns a given response header.""" 40 | return self.urllib3_response.getheader(name, default) 41 | 42 | 43 | class RESTClientObject(object): 44 | 45 | def __init__(self, configuration, pools_size=4, maxsize=None): 46 | # urllib3.PoolManager will pass all kw parameters to connectionpool 47 | # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 48 | # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 49 | # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 50 | # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 51 | 52 | # Session requests manager 53 | self.session = requests.Session() 54 | 55 | # cert_reqs 56 | if configuration.verify_ssl: 57 | cert_reqs = ssl.CERT_REQUIRED 58 | else: 59 | cert_reqs = ssl.CERT_NONE 60 | 61 | # ca_certs 62 | if configuration.ssl_ca_cert: 63 | ca_certs = configuration.ssl_ca_cert 64 | else: 65 | # if not set certificate file, use Mozilla's root certificates. 66 | ca_certs = certifi.where() 67 | 68 | addition_pool_args = {} 69 | if configuration.assert_hostname is not None: 70 | addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 71 | 72 | if configuration.retries is not None: 73 | addition_pool_args['retries'] = configuration.retries 74 | 75 | if maxsize is None: 76 | if configuration.connection_pool_maxsize is not None: 77 | maxsize = configuration.connection_pool_maxsize 78 | else: 79 | maxsize = 4 80 | 81 | 82 | def request(self, method, url, query_params=None, headers=None, 83 | body=None, post_params=None, _preload_content=True, 84 | _request_timeout=None): 85 | """Perform requests. 86 | 87 | :param method: http request method 88 | :param url: http request url 89 | :param query_params: query parameters in the url 90 | :param headers: http request headers 91 | :param body: request json body, for `application/json` 92 | :param post_params: request post parameters, 93 | `application/x-www-form-urlencoded` 94 | and `multipart/form-data` 95 | :param _preload_content: if False, the urllib3.HTTPResponse object will 96 | be returned without reading/decoding response 97 | data. Default is True. 98 | :param _request_timeout: timeout setting for this request. If one 99 | number provided, it will be total request 100 | timeout. It can also be a pair (tuple) of 101 | (connection, read) timeouts. 102 | """ 103 | method = method.upper() 104 | assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 105 | 'PATCH', 'OPTIONS'] 106 | 107 | if post_params and body: 108 | raise ApiValueError( 109 | "body parameter cannot be used with post_params parameter." 110 | ) 111 | 112 | post_params = post_params or {} 113 | headers = headers or {} 114 | 115 | timeout = None 116 | if _request_timeout: 117 | if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 118 | timeout = urllib3.Timeout(total=_request_timeout) 119 | elif (isinstance(_request_timeout, tuple) and 120 | len(_request_timeout) == 2): 121 | timeout = urllib3.Timeout( 122 | connect=_request_timeout[0], read=_request_timeout[1]) 123 | 124 | if 'Content-Type' not in headers: 125 | headers['Content-Type'] = 'application/json' 126 | 127 | data = '' 128 | if post_params: 129 | data = '&'.join([ '='.join(str(el) for el in par) for par in post_params]) 130 | if body: 131 | data = body 132 | 133 | try: 134 | # print('####') 135 | # print('Build the session request with:') 136 | # print('method: ', method) 137 | # print('url: ', url) 138 | # print('headers: ', headers) 139 | # print('query_params: ', query_params) 140 | # print('post_params: ', post_params) 141 | # print('body: ', body) 142 | # print('data: ', data) 143 | # print('####') 144 | 145 | self.session.headers.update(headers) 146 | 147 | r = self.session.request(method, url, data=data) 148 | 149 | # print('Request sent from session is: ', r.request) 150 | # print('url: ', r.request.url) 151 | # print('headers: ', r.request.headers) 152 | # print('body: ', r.request.body) 153 | 154 | # print('Response from session is: ', r) 155 | # print('url: ', r.url) 156 | # print('status_code: ', r.status_code) 157 | # print('headers: ', r.headers) 158 | # print('text: ', r.text) 159 | # print('cookies: ', r.cookies) 160 | except Exception as e: 161 | print('exception is: ', e) 162 | 163 | return r 164 | 165 | def GET(self, url, headers=None, query_params=None, _preload_content=True, 166 | _request_timeout=None): 167 | return self.request("GET", url, 168 | headers=headers, 169 | _preload_content=_preload_content, 170 | _request_timeout=_request_timeout, 171 | query_params=query_params) 172 | 173 | def HEAD(self, url, headers=None, query_params=None, _preload_content=True, 174 | _request_timeout=None): 175 | return self.request("HEAD", url, 176 | headers=headers, 177 | _preload_content=_preload_content, 178 | _request_timeout=_request_timeout, 179 | query_params=query_params) 180 | 181 | def OPTIONS(self, url, headers=None, query_params=None, post_params=None, 182 | body=None, _preload_content=True, _request_timeout=None): 183 | return self.request("OPTIONS", url, 184 | headers=headers, 185 | query_params=query_params, 186 | post_params=post_params, 187 | _preload_content=_preload_content, 188 | _request_timeout=_request_timeout, 189 | body=body) 190 | 191 | def DELETE(self, url, headers=None, query_params=None, body=None, 192 | _preload_content=True, _request_timeout=None): 193 | return self.request("DELETE", url, 194 | headers=headers, 195 | query_params=query_params, 196 | _preload_content=_preload_content, 197 | _request_timeout=_request_timeout, 198 | body=body) 199 | 200 | def POST(self, url, headers=None, query_params=None, post_params=None, 201 | body=None, _preload_content=True, _request_timeout=None): 202 | return self.request("POST", url, 203 | headers=headers, 204 | query_params=query_params, 205 | post_params=post_params, 206 | _preload_content=_preload_content, 207 | _request_timeout=_request_timeout, 208 | body=body) 209 | 210 | def PUT(self, url, headers=None, query_params=None, post_params=None, 211 | body=None, _preload_content=True, _request_timeout=None): 212 | return self.request("PUT", url, 213 | headers=headers, 214 | query_params=query_params, 215 | post_params=post_params, 216 | _preload_content=_preload_content, 217 | _request_timeout=_request_timeout, 218 | body=body) 219 | 220 | def PATCH(self, url, headers=None, query_params=None, post_params=None, 221 | body=None, _preload_content=True, _request_timeout=None): 222 | return self.request("PATCH", url, 223 | headers=headers, 224 | query_params=query_params, 225 | post_params=post_params, 226 | _preload_content=_preload_content, 227 | _request_timeout=_request_timeout, 228 | body=body) 229 | -------------------------------------------------------------------------------- /templates/python/setup.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | from setuptools import setup, find_packages # noqa: H301 6 | 7 | NAME = "{{{projectName}}}" 8 | VERSION = "{{packageVersion}}" 9 | {{#apiInfo}} 10 | {{#apis}} 11 | {{^hasMore}} 12 | # To install the library, run the following 13 | # 14 | # python setup.py install 15 | # 16 | # prerequisite: setuptools 17 | # http://pypi.python.org/pypi/setuptools 18 | 19 | REQUIRES = ["urllib3 >= 1.15", "requests", "six >= 1.10", "certifi", "python-dateutil"] 20 | {{#asyncio}} 21 | REQUIRES.append("aiohttp >= 3.0.0") 22 | {{/asyncio}} 23 | {{#tornado}} 24 | REQUIRES.append("tornado>=4.2,<5") 25 | {{/tornado}} 26 | 27 | setup( 28 | name=NAME, 29 | version=VERSION, 30 | description="{{appName}}", 31 | author_email="{{infoEmail}}", 32 | url="{{packageUrl}}", 33 | keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], 34 | install_requires=REQUIRES, 35 | packages=find_packages(), 36 | include_package_data=True, 37 | long_description="""\ 38 | {{appDescription}} # noqa: E501 39 | """ 40 | ) 41 | {{/hasMore}} 42 | {{/apis}} 43 | {{/apiInfo}} 44 | -------------------------------------------------------------------------------- /templates/python/test-requirements.mustache: -------------------------------------------------------------------------------- 1 | {{^asyncio}} 2 | coverage>=4.0.3 3 | nose>=1.3.7 4 | {{/asyncio}} 5 | {{#asyncio}} 6 | pytest>=3.6.0 7 | pytest-cov>=2.6.1 8 | {{/asyncio}} 9 | pluggy>=0.3.1 10 | py>=1.4.31 11 | randomize>=0.13 12 | -------------------------------------------------------------------------------- /templates/python/tox.mustache: -------------------------------------------------------------------------------- 1 | [tox] 2 | {{^asyncio}} 3 | envlist = py27, py3 4 | {{/asyncio}} 5 | {{#asyncio}} 6 | envlist = py3 7 | {{/asyncio}} 8 | 9 | [testenv] 10 | deps=-r{toxinidir}/requirements.txt 11 | -r{toxinidir}/test-requirements.txt 12 | 13 | commands= 14 | {{^asyncio}} 15 | nosetests \ 16 | [] 17 | {{/asyncio}} 18 | {{#asyncio}} 19 | pytest -v --cov petstore_api 20 | {{/asyncio}} 21 | -------------------------------------------------------------------------------- /templates/python/travis.mustache: -------------------------------------------------------------------------------- 1 | # ref: https://docs.travis-ci.com/user/languages/python 2 | language: python 3 | python: 4 | - "2.7" 5 | - "3.2" 6 | - "3.3" 7 | - "3.4" 8 | - "3.5" 9 | #- "3.5-dev" # 3.5 development branch 10 | #- "nightly" # points to the latest development branch e.g. 3.6-dev 11 | # command to install dependencies 12 | install: "pip install -r requirements.txt" 13 | # command to run tests 14 | script: nosetests 15 | -------------------------------------------------------------------------------- /test/python-sdk.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import time 3 | import hmac 4 | import json 5 | import hashlib 6 | import uuid as uuid_library 7 | import six.moves.urllib as urllib 8 | import private_instagram_sdk 9 | from private_instagram_sdk.rest import ApiException 10 | from private_instagram_sdk.api_client import ApiClient 11 | from pprint import pprint 12 | 13 | USERNAME, PASSWORD = 'username', 'password' 14 | IG_SIG_KEY = '99e16edcca71d7c1f3fd74d447f6281bd5253a623000a55ed0b60014467a53b1' 15 | 16 | def hex_digest(*args): 17 | m = hashlib.md5() 18 | m.update(b''.join([arg.encode('utf-8') for arg in args])) 19 | return m.hexdigest() 20 | 21 | def generate_device_id(seed): 22 | volatile_seed = "12345" # Important ! :) :) 23 | m = hashlib.md5() 24 | m.update(seed.encode('utf-8') + volatile_seed.encode('utf-8')) 25 | return 'android-' + m.hexdigest()[:16] 26 | 27 | phone_id = str(uuid_library.uuid4()) 28 | uuid = str(uuid_library.uuid4()) 29 | device_id = generate_device_id(hex_digest(USERNAME, USERNAME)) 30 | data = json.dumps({ 31 | 'phone_id': phone_id, 32 | 'device_id': device_id, 33 | 'guid': uuid, 34 | 'username': USERNAME, 35 | 'password': PASSWORD, 36 | }) 37 | 38 | DEVICE = { 39 | 'instagram_version': '26.0.0.10.86', 40 | 'android_version': 24, 41 | 'android_release': '7.0', 42 | 'dpi': '640dpi', 43 | 'resolution': '1440x2560', 44 | 'manufacturer': 'HUAWEI', 45 | 'device': 'LON-L29', 46 | 'model': 'HWLON', 47 | 'cpu': 'hi3660' 48 | } 49 | 50 | USER_AGENT_BASE = ( 51 | 'Instagram {instagram_version} ' 52 | 'Android ({android_version}/{android_release}; ' 53 | '{dpi}; {resolution}; {manufacturer}; ' 54 | '{device}; {model}; {cpu}; en_US)' 55 | ) 56 | 57 | user_agent = USER_AGENT_BASE.format(**DEVICE) # just insert params 58 | 59 | # create an instance of the API class and add User-Agent 60 | api_client = private_instagram_sdk.ApiClient() 61 | api_client.user_agent = user_agent 62 | 63 | ig_auth = private_instagram_sdk.AuthApi(api_client) 64 | ig_users = private_instagram_sdk.UserApi(api_client) 65 | 66 | ig_sig_key_version = 4 # int | (optional) 67 | signed_body = hmac.new(IG_SIG_KEY.encode('utf-8'), data.encode('utf-8'), hashlib.sha256).hexdigest() + '.' + urllib.parse.quote(data) # str | (optional) 68 | 69 | print('user-agent:\n', user_agent) 70 | body = 'ig_sig_key_version=4&signed_body={body}'.format(body=signed_body) 71 | print('body:\n', body) 72 | 73 | try: 74 | # Login user to Instagram 75 | api_response = ig_auth.login(body) 76 | r = api_response 77 | # pprint(api_response) 78 | # print('Request sent from session is: ', r.request) 79 | # print('url: ', r.request.url) 80 | # # print('headers: ', r.request.headers) 81 | # print('body: ', r.request.body) 82 | 83 | # print('Response from session is: ', r) 84 | # print('url: ', r.url) 85 | # print('status_code: ', r.status_code) 86 | # # print('headers: ', r.headers) 87 | # print('text: ', r.text) 88 | # # print('cookies: ', r.cookies) 89 | 90 | logged_in_user = r.json() 91 | print(type(logged_in_user)) 92 | print(logged_in_user) 93 | # if logged_in_user['logged_in_user']: 94 | # print('logged_in_user!') 95 | # if logged_in_user['logged_in_user']['pk']: 96 | # print('WE HAVE PK for current User!') 97 | me_id = logged_in_user['logged_in_user']['pk'] 98 | print('me_id: {}'.format(me_id)) 99 | # get me (current logged in user) 100 | me = ig_users.getUser(me_id) 101 | # print('Request sent from session is: ', me.request) 102 | # print('url: ', me.request.url) 103 | # print('headers: ', me.request.headers) 104 | # print('body: ', me.request.body) 105 | 106 | print('Response from session is: ', r) 107 | print('url: ', me.url) 108 | print('status_code: ', me.status_code) 109 | print('headers: ', me.headers) 110 | print('text: ', me.text) 111 | print('cookies: ', me.cookies) 112 | 113 | except Exception as e: 114 | print("Exception bad thing: %s\n" % e) 115 | -------------------------------------------------------------------------------- /tools/auto_generate_sdks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | cd sdks 3 | 4 | # create the python sdk 5 | # cd python 6 | # openapi-generator generate -i ../api/instagram.yaml -g python -o python --config ../configs/python.yaml 7 | openapi-generator generate -i ../instagram-api.bundle.json -g python -o python --config ../configs/python.yaml --skip-validate-spec -------------------------------------------------------------------------------- /tools/example_login.py: -------------------------------------------------------------------------------- 1 | import uuid as uuid_library 2 | import hmac 3 | import json 4 | import hashlib 5 | import requests 6 | import six.moves.urllib as urllib 7 | 8 | USERNAME, PASSWORD = 'username', 'password' 9 | 10 | LOGIN_URL = 'https://i.instagram.com/api/v1/accounts/login/' 11 | REQUEST_HEADERS = { 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8' } 12 | IG_SIG_KEY = '99e16edcca71d7c1f3fd74d447f6281bd5253a623000a55ed0b60014467a53b1' 13 | 14 | # I have more devices here: 15 | # https://github.com/instagrambot/instabot/blob/72d10447986db39ac95f3d0980936d9c08428b02/instabot/api/devices.py 16 | # idk which to use, let's for now use this one, because it is just works 17 | 18 | DEVICE = { 19 | 'instagram_version': '26.0.0.10.86', 20 | 'android_version': 24, 21 | 'android_release': '7.0', 22 | 'dpi': '640dpi', 23 | 'resolution': '1440x2560', 24 | 'manufacturer': 'HUAWEI', 25 | 'device': 'LON-L29', 26 | 'model': 'HWLON', 27 | 'cpu': 'hi3660' 28 | } 29 | 30 | USER_AGENT_BASE = ( 31 | 'Instagram {instagram_version} ' 32 | 'Android ({android_version}/{android_release}; ' 33 | '{dpi}; {resolution}; {manufacturer}; ' 34 | '{device}; {model}; {cpu}; en_US)' 35 | ) 36 | 37 | user_agent = USER_AGENT_BASE.format(**DEVICE) # just insert params 38 | 39 | def hex_digest(*args): 40 | m = hashlib.md5() 41 | m.update(b''.join([arg.encode('utf-8') for arg in args])) 42 | return m.hexdigest() 43 | 44 | def generate_device_id(seed): 45 | volatile_seed = "12345" # Important ! :) :) 46 | m = hashlib.md5() 47 | m.update(seed.encode('utf-8') + volatile_seed.encode('utf-8')) 48 | return 'android-' + m.hexdigest()[:16] 49 | 50 | def generate_uuid(): 51 | return str(uuid_library.uuid4()) 52 | 53 | def generate_signature(data): 54 | body = hmac.new(IG_SIG_KEY.encode('utf-8'), data.encode('utf-8'), 55 | hashlib.sha256).hexdigest() + '.' + urllib.parse.quote(data) 56 | signature = 'ig_sig_key_version=4&signed_body={body}' 57 | return signature.format(body=body) 58 | 59 | phone_id = generate_uuid() 60 | uuid = generate_uuid() 61 | device_id = generate_device_id(hex_digest(USERNAME, USERNAME)) 62 | 63 | data = json.dumps({ 64 | 'phone_id': phone_id, 65 | 'device_id': device_id, 66 | 'guid': uuid, 67 | 'username': USERNAME, 68 | 'password': PASSWORD, 69 | }) 70 | 71 | data = generate_signature(data) 72 | 73 | session = requests.Session() 74 | session.headers.update(REQUEST_HEADERS) 75 | session.headers.update({'User-Agent': user_agent}) 76 | response = session.post(LOGIN_URL, data=data) 77 | 78 | assert response.status_code == 200 79 | print(response.text) 80 | # print(response.links) 81 | print(response.url) 82 | print(response.headers) 83 | 84 | #y = json.dumps(response.content) 85 | #print(y) 86 | #print(response.content) 87 | --------------------------------------------------------------------------------