Sign inSign up

dokeraj/simple-api-caller

By dokeraj

Updated about 2 years ago

Make an API request by starting this docker image

Image
API management
Developer tools
0

1.3K

dokeraj/simple-api-caller repository overview

This is a python script that when you start the container makes an API request(s) and stops the container.

Rationale

If you need to make an API request that can be triggered manually one time (per starting the container) - look no further! You can make any type of API requests (PUT, POST, GET...). You can add multiple APIs that will be called by starting the container.

Note: they will be called synchronously - and if there is error in one of those API calls, then the whole container will stop

Supported Architectures

  • armhf - Raspberry Pi 3 and 4 and 5
  • amd64

The tag latest is multi-arch, so you can use it for any architecture.

Usage

  1. You must create the following file named config.yml and place it in a folder, that will be binded to a volume. Otherwise you cannot use this docker image.

config.yml

  ## MANDATORY. The URL you want to call
  # ex. http://192.168.100.2:8384 or https://mydomain.com
- url: <INSERT HTTP OR HTTPS URL>
  ## MANDATORY. The URL you use to access the GUI. Note that if you are accessing the local syncthing instance, you need to have both containers be in the same docker network, and then just use the name of the syncthing container like http://syncthing:8384
  # ex. can be `GET`, `OPTIONS`, `HEAD`, `POST`, `PUT`, `PATCH`, or `DELETE`
  http_method: <INPUT THE HTTP METHOD>
  ## OPTIONAL. You can set the payload here in json format. NOTE YOU CAN DELETE THIS FIELD ENTIRELY IF YOU'RE NOT USING IT
  # ex. {"field1":"value1","field2":"value2"}
  payload: <INSERT YOU JSON PAYLOAD>
  ## OPTIONAL. You can set the HEADERS here. NOTE THAT THE fields `key` and `value` must be present if this HEADERS object is specified. Also note that the `key` and `value` is a list, so you can specify multiple headers.
  headers:
    - key: key1
      value: val1
    - key: key2
      value: val2
  ## SINCE THIS YAML FILE IS AN ARRAY YOU CAN SEE THAT WE HAVE THE SAME SCHEMA BELOW (BUT WE'VE REMOVED THE PAYLOAD AND HEADERS)
- url: <INSERT HTTP OR HTTPS URL>
  http_method: <INPUT THE HTTP METHOD>

The config.yml can also be found here.

Docker create command

docker create \
--name=simple-api-caller \
-d \
-e API_TIMEOUT=3 \
-v /path/to/your/yaml/config/file:/yaml \
dokeraj/simple-api-caller:latest
Creation flags explanation
flagFunction
-e API_TIMEOUT=3Optional. You can set the API timeout in seconds. Note: If not set this defaults to 3 seconds.
-v /path/to/your/yaml/config/file:/yamlMandatory. This bind should point to where you have placed your config.yml file, so simple-api-caller can read it on startup.

Github project

Source code can be found here: Simple-API-caller

Tag summary

Content type

Image

Digest

sha256:23a4f033e

Size

24 MB

Last updated

about 2 years ago

docker pull dokeraj/simple-api-caller