Skip to content
Snippets Groups Projects
Hahn Axel (hahn)'s avatar
Hahn Axel (hahn) authored
9a87e5a1
History
Name Last commit Last update
docs
tests
README.md
rest-api-client.sh

Bash REST API client

This is a bash solution to script REST API calls.

The specialties of this component are

  • It was build to simplify http calls and handle http response for scripts
  • After making a request the response stays is in memory. There is no output to any file to grep something or to cleanup after usage.
  • Its functions feel a bit like class methods, i.e. http.getResponse to get the response body or http.getResponseHeader for the Http response header
  • This component wraps curl - ist supports any http method
  • works with anonymous requests and Basic Authentication
  • The response can be stored ... and reimported later. After import you can use the http.get* functions to fetch results from the former request.
  • Caching support for GET requests with a given TTL: if you repeat a request to the same url and ttl was not reached yet then you continue with the cached result

👤 Author: Axel Hahn; Institute for Medical Education; University of Bern
📄 Source: https://git-repo.iml.unibe.ch/iml-open-source/bash-rest-api-client
📜 License: GNU GPL 3.0
📗 Docs: https://os-docs.iml.unibe.ch/bash-rest-api-client/

http.init
http.makeRequest 'http://www.example.com/'

This stores the response in a variable and has no output. Now you can get its data, eg

  • http.getStatuscode - This returns the Http status code
  • http.getResponseHeader - print Http response header
  • http.getResponseData - get data from curl
  • http.getResponse - get response body