# portainer_api PortainerApi - JavaScript client for portainer_api Portainer API is an HTTP API served by Portainer. It is used by the Portainer UI and everything you can do with the UI can be done using the HTTP API. Examples are available at https://gist.github.com/deviantony/77026d402366b4b43fa5918d41bc42f8 You can find out more about Portainer at [http://portainer.io](http://portainer.io) and get some support on [Slack](http://portainer.io/slack/). # Authentication Most of the API endpoints require to be authenticated as well as some level of authorization to be used. Portainer API uses JSON Web Token to manage authentication and thus requires you to provide a token in the **Authorization** header of each request with the **Bearer** authentication mechanism. Example: ``` Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInJvbGUiOjEsImV4cCI6MTQ5OTM3NjE1NH0.NJ6vE8FY1WG6jsRQzfMqeatJ4vh2TWAeeYfDhP71YEE ``` # Security Each API endpoint has an associated access policy, it is documented in the description of each endpoint. Different access policies are available: * Public access * Authenticated access * Restricted access * Administrator access ### Public access No authentication is required to access the endpoints with this access policy. ### Authenticated access Authentication is required to access the endpoints with this access policy. ### Restricted access Authentication is required to access the endpoints with this access policy. Extra-checks might be added to ensure access to the resource is granted. Returned data might also be filtered. ### Administrator access Authentication as well as an administrator role are required to access the endpoints with this access policy. # Execute Docker requests Portainer **DO NOT** expose specific endpoints to manage your Docker resources (create a container, remove a volume, etc...). Instead, it acts as a reverse-proxy to the Docker HTTP API. This means that you can execute Docker requests **via** the Portainer HTTP API. To do so, you can use the `/endpoints/{id}/docker` Portainer API endpoint (which is not documented below due to Swagger limitations). This endpoint has a restricted access policy so you still need to be authenticated to be able to query this endpoint. Any query on this endpoint will be proxied to the Docker API of the associated endpoint (requests and responses objects are the same as documented in the Docker API). **NOTE**: You can find more information on how to query the Docker API in the [Docker official documentation](https://docs.docker.com/engine/api/v1.30/) as well as in [this Portainer example](https://gist.github.com/deviantony/77026d402366b4b43fa5918d41bc42f8). This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: - API version: 1.20.0 - Package version: 1.20.0 - Build package: io.swagger.codegen.languages.JavascriptClientCodegen ## Installation ### For [Node.js](https://nodejs.org/) #### npm To publish the library as a [npm](https://www.npmjs.com/), please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages). Then install it via: ```shell npm install portainer_api --save ``` ##### Local development To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run: ```shell npm install ``` Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`: ```shell npm link ``` Finally, switch to the directory you want to use your portainer_api from, and run: ```shell npm link /path/to/ ``` You should now be able to `require('portainer_api')` in javascript files from the directory you ran the last command above from. #### git # If the library is hosted at a git repository, e.g. https://github.com/YOUR_USERNAME/portainer_api then install it via: ```shell npm install YOUR_USERNAME/portainer_api --save ``` ### For browser The library also works in the browser environment via npm and [browserify](http://browserify.org/). After following the above steps with Node.js and installing browserify with `npm install -g browserify`, perform the following (assuming *main.js* is your entry file, that's to say your javascript file where you actually use this library): ```shell browserify main.js > bundle.js ``` Then include *bundle.js* in the HTML pages. ### Webpack Configuration Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config: ```javascript module: { rules: [ { parser: { amd: false } } ] } ``` ## Getting Started Please follow the [installation](#installation) instruction and execute the following JS code: ```javascript var PortainerApi = require('portainer_api'); var api = new PortainerApi.AuthApi() var body = new PortainerApi.AuthenticateUserRequest(); // {AuthenticateUserRequest} Credentials used for authentication var callback = function(error, data, response) { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }; api.authenticateUser(body, callback); ``` ## Documentation for API Endpoints All URIs are relative to *http://portainer.domain/api* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *PortainerApi.AuthApi* | [**authenticateUser**](docs/AuthApi.md#authenticateUser) | **POST** /auth | Authenticate a user *PortainerApi.DockerhubApi* | [**dockerHubInspect**](docs/DockerhubApi.md#dockerHubInspect) | **GET** /dockerhub | Retrieve DockerHub information *PortainerApi.DockerhubApi* | [**dockerHubUpdate**](docs/DockerhubApi.md#dockerHubUpdate) | **PUT** /dockerhub | Update DockerHub information *PortainerApi.EndpointGroupsApi* | [**endpointGroupAccessUpdate**](docs/EndpointGroupsApi.md#endpointGroupAccessUpdate) | **PUT** /endpoint_groups/{id}/access | Manage accesses to an endpoint group *PortainerApi.EndpointGroupsApi* | [**endpointGroupCreate**](docs/EndpointGroupsApi.md#endpointGroupCreate) | **POST** /endpoint_groups | Create a new endpoint *PortainerApi.EndpointGroupsApi* | [**endpointGroupDelete**](docs/EndpointGroupsApi.md#endpointGroupDelete) | **DELETE** /endpoint_groups/{id} | Remove an endpoint group *PortainerApi.EndpointGroupsApi* | [**endpointGroupInspect**](docs/EndpointGroupsApi.md#endpointGroupInspect) | **GET** /endpoint_groups/{id} | Inspect an endpoint group *PortainerApi.EndpointGroupsApi* | [**endpointGroupList**](docs/EndpointGroupsApi.md#endpointGroupList) | **GET** /endpoint_groups | List endpoint groups *PortainerApi.EndpointGroupsApi* | [**endpointGroupUpdate**](docs/EndpointGroupsApi.md#endpointGroupUpdate) | **PUT** /endpoint_groups/{id} | Update an endpoint group *PortainerApi.EndpointsApi* | [**endpointAccessUpdate**](docs/EndpointsApi.md#endpointAccessUpdate) | **PUT** /endpoints/{id}/access | Manage accesses to an endpoint *PortainerApi.EndpointsApi* | [**endpointCreate**](docs/EndpointsApi.md#endpointCreate) | **POST** /endpoints | Create a new endpoint *PortainerApi.EndpointsApi* | [**endpointDelete**](docs/EndpointsApi.md#endpointDelete) | **DELETE** /endpoints/{id} | Remove an endpoint *PortainerApi.EndpointsApi* | [**endpointInspect**](docs/EndpointsApi.md#endpointInspect) | **GET** /endpoints/{id} | Inspect an endpoint *PortainerApi.EndpointsApi* | [**endpointJob**](docs/EndpointsApi.md#endpointJob) | **POST** /endpoints/{id}/job | Execute a job on the endpoint host *PortainerApi.EndpointsApi* | [**endpointList**](docs/EndpointsApi.md#endpointList) | **GET** /endpoints | List endpoints *PortainerApi.EndpointsApi* | [**endpointUpdate**](docs/EndpointsApi.md#endpointUpdate) | **PUT** /endpoints/{id} | Update an endpoint *PortainerApi.RegistriesApi* | [**registryAccessUpdate**](docs/RegistriesApi.md#registryAccessUpdate) | **PUT** /registries/{id}/access | Manage accesses to a registry *PortainerApi.RegistriesApi* | [**registryCreate**](docs/RegistriesApi.md#registryCreate) | **POST** /registries | Create a new registry *PortainerApi.RegistriesApi* | [**registryDelete**](docs/RegistriesApi.md#registryDelete) | **DELETE** /registries/{id} | Remove a registry *PortainerApi.RegistriesApi* | [**registryInspect**](docs/RegistriesApi.md#registryInspect) | **GET** /registries/{id} | Inspect a registry *PortainerApi.RegistriesApi* | [**registryList**](docs/RegistriesApi.md#registryList) | **GET** /registries | List registries *PortainerApi.RegistriesApi* | [**registryUpdate**](docs/RegistriesApi.md#registryUpdate) | **PUT** /registries/{id} | Update a registry *PortainerApi.ResourceControlsApi* | [**resourceControlCreate**](docs/ResourceControlsApi.md#resourceControlCreate) | **POST** /resource_controls | Create a new resource control *PortainerApi.ResourceControlsApi* | [**resourceControlDelete**](docs/ResourceControlsApi.md#resourceControlDelete) | **DELETE** /resource_controls/{id} | Remove a resource control *PortainerApi.ResourceControlsApi* | [**resourceControlUpdate**](docs/ResourceControlsApi.md#resourceControlUpdate) | **PUT** /resource_controls/{id} | Update a resource control *PortainerApi.SettingsApi* | [**publicSettingsInspect**](docs/SettingsApi.md#publicSettingsInspect) | **GET** /settings/public | Retrieve Portainer public settings *PortainerApi.SettingsApi* | [**settingsInspect**](docs/SettingsApi.md#settingsInspect) | **GET** /settings | Retrieve Portainer settings *PortainerApi.SettingsApi* | [**settingsLDAPCheck**](docs/SettingsApi.md#settingsLDAPCheck) | **PUT** /settings/authentication/checkLDAP | Test LDAP connectivity *PortainerApi.SettingsApi* | [**settingsUpdate**](docs/SettingsApi.md#settingsUpdate) | **PUT** /settings | Update Portainer settings *PortainerApi.StacksApi* | [**stackCreate**](docs/StacksApi.md#stackCreate) | **POST** /stacks | Deploy a new stack *PortainerApi.StacksApi* | [**stackDelete**](docs/StacksApi.md#stackDelete) | **DELETE** /stacks/{id} | Remove a stack *PortainerApi.StacksApi* | [**stackFileInspect**](docs/StacksApi.md#stackFileInspect) | **GET** /stacks/{id}/file | Retrieve the content of the Stack file for the specified stack *PortainerApi.StacksApi* | [**stackInspect**](docs/StacksApi.md#stackInspect) | **GET** /stacks/{id} | Inspect a stack *PortainerApi.StacksApi* | [**stackList**](docs/StacksApi.md#stackList) | **GET** /stacks | List stacks *PortainerApi.StacksApi* | [**stackMigrate**](docs/StacksApi.md#stackMigrate) | **POST** /stacks/{id}/migrate | Migrate a stack to another endpoint *PortainerApi.StacksApi* | [**stackUpdate**](docs/StacksApi.md#stackUpdate) | **PUT** /stacks/{id} | Update a stack *PortainerApi.StatusApi* | [**statusInspect**](docs/StatusApi.md#statusInspect) | **GET** /status | Check Portainer status *PortainerApi.TagsApi* | [**tagCreate**](docs/TagsApi.md#tagCreate) | **POST** /tags | Create a new tag *PortainerApi.TagsApi* | [**tagDelete**](docs/TagsApi.md#tagDelete) | **DELETE** /tags/{id} | Remove a tag *PortainerApi.TagsApi* | [**tagList**](docs/TagsApi.md#tagList) | **GET** /tags | List tags *PortainerApi.TeamMembershipsApi* | [**teamMembershipCreate**](docs/TeamMembershipsApi.md#teamMembershipCreate) | **POST** /team_memberships | Create a new team membership *PortainerApi.TeamMembershipsApi* | [**teamMembershipDelete**](docs/TeamMembershipsApi.md#teamMembershipDelete) | **DELETE** /team_memberships/{id} | Remove a team membership *PortainerApi.TeamMembershipsApi* | [**teamMembershipList**](docs/TeamMembershipsApi.md#teamMembershipList) | **GET** /team_memberships | List team memberships *PortainerApi.TeamMembershipsApi* | [**teamMembershipUpdate**](docs/TeamMembershipsApi.md#teamMembershipUpdate) | **PUT** /team_memberships/{id} | Update a team membership *PortainerApi.TeamsApi* | [**teamCreate**](docs/TeamsApi.md#teamCreate) | **POST** /teams | Create a new team *PortainerApi.TeamsApi* | [**teamDelete**](docs/TeamsApi.md#teamDelete) | **DELETE** /teams/{id} | Remove a team *PortainerApi.TeamsApi* | [**teamInspect**](docs/TeamsApi.md#teamInspect) | **GET** /teams/{id} | Inspect a team *PortainerApi.TeamsApi* | [**teamList**](docs/TeamsApi.md#teamList) | **GET** /teams | List teams *PortainerApi.TeamsApi* | [**teamMembershipsInspect**](docs/TeamsApi.md#teamMembershipsInspect) | **GET** /teams/{id}/memberships | Inspect a team memberships *PortainerApi.TeamsApi* | [**teamUpdate**](docs/TeamsApi.md#teamUpdate) | **PUT** /teams/{id} | Update a team *PortainerApi.TemplatesApi* | [**templateCreate**](docs/TemplatesApi.md#templateCreate) | **POST** /templates | Create a new template *PortainerApi.TemplatesApi* | [**templateDelete**](docs/TemplatesApi.md#templateDelete) | **DELETE** /templates/{id} | Remove a template *PortainerApi.TemplatesApi* | [**templateInspect**](docs/TemplatesApi.md#templateInspect) | **GET** /templates/{id} | Inspect a template *PortainerApi.TemplatesApi* | [**templateList**](docs/TemplatesApi.md#templateList) | **GET** /templates | List available templates *PortainerApi.TemplatesApi* | [**templateUpdate**](docs/TemplatesApi.md#templateUpdate) | **PUT** /templates/{id} | Update a template *PortainerApi.UploadApi* | [**uploadTLS**](docs/UploadApi.md#uploadTLS) | **POST** /upload/tls/{certificate} | Upload TLS files *PortainerApi.UsersApi* | [**userAdminCheck**](docs/UsersApi.md#userAdminCheck) | **GET** /users/admin/check | Check administrator account existence *PortainerApi.UsersApi* | [**userAdminInit**](docs/UsersApi.md#userAdminInit) | **POST** /users/admin/init | Initialize administrator account *PortainerApi.UsersApi* | [**userCreate**](docs/UsersApi.md#userCreate) | **POST** /users | Create a new user *PortainerApi.UsersApi* | [**userDelete**](docs/UsersApi.md#userDelete) | **DELETE** /users/{id} | Remove a user *PortainerApi.UsersApi* | [**userInspect**](docs/UsersApi.md#userInspect) | **GET** /users/{id} | Inspect a user *PortainerApi.UsersApi* | [**userList**](docs/UsersApi.md#userList) | **GET** /users | List users *PortainerApi.UsersApi* | [**userMembershipsInspect**](docs/UsersApi.md#userMembershipsInspect) | **GET** /users/{id}/memberships | Inspect a user memberships *PortainerApi.UsersApi* | [**userPasswordCheck**](docs/UsersApi.md#userPasswordCheck) | **POST** /users/{id}/passwd | Check password validity for a user *PortainerApi.UsersApi* | [**userUpdate**](docs/UsersApi.md#userUpdate) | **PUT** /users/{id} | Update a user ## Documentation for Models - [PortainerApi.AuthenticateUserRequest](docs/AuthenticateUserRequest.md) - [PortainerApi.AuthenticateUserResponse](docs/AuthenticateUserResponse.md) - [PortainerApi.AzureCredentials](docs/AzureCredentials.md) - [PortainerApi.DockerHub](docs/DockerHub.md) - [PortainerApi.DockerHubSubset](docs/DockerHubSubset.md) - [PortainerApi.DockerHubUpdateRequest](docs/DockerHubUpdateRequest.md) - [PortainerApi.Endpoint](docs/Endpoint.md) - [PortainerApi.EndpointAccessUpdateRequest](docs/EndpointAccessUpdateRequest.md) - [PortainerApi.EndpointGroup](docs/EndpointGroup.md) - [PortainerApi.EndpointGroupAccessUpdateRequest](docs/EndpointGroupAccessUpdateRequest.md) - [PortainerApi.EndpointGroupCreateRequest](docs/EndpointGroupCreateRequest.md) - [PortainerApi.EndpointGroupListResponse](docs/EndpointGroupListResponse.md) - [PortainerApi.EndpointGroupUpdateRequest](docs/EndpointGroupUpdateRequest.md) - [PortainerApi.EndpointJobRequest](docs/EndpointJobRequest.md) - [PortainerApi.EndpointListResponse](docs/EndpointListResponse.md) - [PortainerApi.EndpointSubset](docs/EndpointSubset.md) - [PortainerApi.EndpointUpdateRequest](docs/EndpointUpdateRequest.md) - [PortainerApi.GenericError](docs/GenericError.md) - [PortainerApi.LDAPGroupSearchSettings](docs/LDAPGroupSearchSettings.md) - [PortainerApi.LDAPSearchSettings](docs/LDAPSearchSettings.md) - [PortainerApi.LDAPSettings](docs/LDAPSettings.md) - [PortainerApi.Pair](docs/Pair.md) - [PortainerApi.PublicSettingsInspectResponse](docs/PublicSettingsInspectResponse.md) - [PortainerApi.Registry](docs/Registry.md) - [PortainerApi.RegistryAccessUpdateRequest](docs/RegistryAccessUpdateRequest.md) - [PortainerApi.RegistryCreateRequest](docs/RegistryCreateRequest.md) - [PortainerApi.RegistryListResponse](docs/RegistryListResponse.md) - [PortainerApi.RegistrySubset](docs/RegistrySubset.md) - [PortainerApi.RegistryUpdateRequest](docs/RegistryUpdateRequest.md) - [PortainerApi.ResourceControl](docs/ResourceControl.md) - [PortainerApi.ResourceControlCreateRequest](docs/ResourceControlCreateRequest.md) - [PortainerApi.ResourceControlUpdateRequest](docs/ResourceControlUpdateRequest.md) - [PortainerApi.Settings](docs/Settings.md) - [PortainerApi.SettingsBlackListedLabels](docs/SettingsBlackListedLabels.md) - [PortainerApi.SettingsLDAPCheckRequest](docs/SettingsLDAPCheckRequest.md) - [PortainerApi.SettingsUpdateRequest](docs/SettingsUpdateRequest.md) - [PortainerApi.Stack](docs/Stack.md) - [PortainerApi.StackCreateRequest](docs/StackCreateRequest.md) - [PortainerApi.StackEnv](docs/StackEnv.md) - [PortainerApi.StackFileInspectResponse](docs/StackFileInspectResponse.md) - [PortainerApi.StackListResponse](docs/StackListResponse.md) - [PortainerApi.StackMigrateRequest](docs/StackMigrateRequest.md) - [PortainerApi.StackUpdateRequest](docs/StackUpdateRequest.md) - [PortainerApi.Status](docs/Status.md) - [PortainerApi.TLSConfiguration](docs/TLSConfiguration.md) - [PortainerApi.Tag](docs/Tag.md) - [PortainerApi.TagCreateRequest](docs/TagCreateRequest.md) - [PortainerApi.TagListResponse](docs/TagListResponse.md) - [PortainerApi.Team](docs/Team.md) - [PortainerApi.TeamCreateRequest](docs/TeamCreateRequest.md) - [PortainerApi.TeamListResponse](docs/TeamListResponse.md) - [PortainerApi.TeamMembership](docs/TeamMembership.md) - [PortainerApi.TeamMembershipCreateRequest](docs/TeamMembershipCreateRequest.md) - [PortainerApi.TeamMembershipListResponse](docs/TeamMembershipListResponse.md) - [PortainerApi.TeamMembershipUpdateRequest](docs/TeamMembershipUpdateRequest.md) - [PortainerApi.TeamMembershipsResponse](docs/TeamMembershipsResponse.md) - [PortainerApi.TeamUpdateRequest](docs/TeamUpdateRequest.md) - [PortainerApi.Template](docs/Template.md) - [PortainerApi.TemplateCreateRequest](docs/TemplateCreateRequest.md) - [PortainerApi.TemplateEnv](docs/TemplateEnv.md) - [PortainerApi.TemplateEnvSelect](docs/TemplateEnvSelect.md) - [PortainerApi.TemplateListResponse](docs/TemplateListResponse.md) - [PortainerApi.TemplateRepository](docs/TemplateRepository.md) - [PortainerApi.TemplateUpdateRequest](docs/TemplateUpdateRequest.md) - [PortainerApi.TemplateVolume](docs/TemplateVolume.md) - [PortainerApi.User](docs/User.md) - [PortainerApi.UserAdminInitRequest](docs/UserAdminInitRequest.md) - [PortainerApi.UserCreateRequest](docs/UserCreateRequest.md) - [PortainerApi.UserListResponse](docs/UserListResponse.md) - [PortainerApi.UserMembershipsResponse](docs/UserMembershipsResponse.md) - [PortainerApi.UserPasswordCheckRequest](docs/UserPasswordCheckRequest.md) - [PortainerApi.UserPasswordCheckResponse](docs/UserPasswordCheckResponse.md) - [PortainerApi.UserSubset](docs/UserSubset.md) - [PortainerApi.UserUpdateRequest](docs/UserUpdateRequest.md) ## Documentation for Authorization ### jwt - **Type**: API key - **API key parameter name**: Authorization - **Location**: HTTP header