• Stars
    star
    88
  • Rank 375,465 (Top 8 %)
  • Language
    Erlang
  • License
    MIT License
  • Created over 12 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Erlang Rest Client

Hex.pm restclient -- An erlang REST Client library

DESCRIPTION

restclient is a library to help with consuming RESTful web services. It supports encoding and decoding JSON, Percent and XML and comes with a convenience function for working with urls and query parameters.

USAGE

Include restclient as a rebar dependency with:

{deps, [{restc, ".*", {git, "git://github.com/kivra/restclient.git", {tag, "0.8.2"}}}]}.

You have to start inets before using the client and if you want to use https make sure to start ssl before. Then you can use the client as:

Erlang/OTP 19 [erts-8.2] [source] [64-bit] [smp:8:8] [async-threads:0] [kernel-poll:false]

Eshell V8.2  (abort with ^G)
1> application:ensure_all_started(restc).
{ok,[idna,mimerl,certifi,ssl_verify_fun,metrics,hackney,
     mochiweb_util,restc]}

2> restc:request(get, "https://api.github.com").
{ok,200,
    [{<<"Server">>,<<"GitHub.com">>},
     {<<"Date">>,<<"Thu, 11 May 2017 07:36:16 GMT">>},
     {<<"Content-Type">>,<<"application/json; charset=utf-8">>},
     {<<"Content-Length">>,<<"2039">>},
     {<<"Status">>,<<"200 OK">>},
     {<<"X-GitHub-Req"...>>,<<"8E05:5C9"...>>}],
    [{<<"current_user_url">>,<<"https://api.github.com/user">>},
     {<<"current_user_authorizations_html_url">>,
      <<"https://github.com/settings/connections/applications{/client_id}">>},
     {<<"authorizations_url">>,
      <<"https://api.github.com/authorizations">>},
     {<<...>>,...},
     {...}|...]}
3> restc:request(get, "https://api.github.com/herp-derp-404", [200]).
{error,404,
       [{<<"Server">>,<<"GitHub.com">>},
        {<<"Date">>,<<"Thu, 11 May 2017 07:37:27 GMT">>},
        {<<"Content-Type">>,<<"application/json; charset=utf-8">>},
        {<<"Content-Length">>,<<"77">>},
        {<<"Status">>,<<"404 Not Found">>},
        {<<"X-RateLimit-Limit">>,<<"60">>},
        {<<"X-RateLimit-Remaining">>,<<"56">>},
        {<<"X-RateLimit-Reset">>,<<"1494491776">>},
        {<<"X-GitHub-Media-Type">>,<<"github.v3">>},
        {<<"Access-Control-Expose-Headers">>,
         <<"ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit"...>>},
        {<<"Access-Control-Allow-Origin">>,<<"*">>},
        {<<"Content-Security-Policy">>,<<"default-src 'none'">>},
        {<<"Strict-Transport-Security">>,
         <<"max-age=31536000; includeSubdomains; preload">>},
        {<<"X-Content-Type-Options">>,<<"nosniff">>},
        {<<"X-Frame-Options">>,<<"deny">>},
        {<<"X-XSS-Protection">>,<<"1; mode=block">>},
        {<<"X-GitHub-Request-Id">>,
         <<"8C1D:5C90:54F34B8:6C6FF4D:59"...>>}],
       [{<<"message">>,<<"Not Found">>},
        {<<"documentation_url">>,
         <<"https://developer.github.com/v3">>}]}

There's also convenience functions for working with urls and query string:

	7> restc:construct_url("http://www.example.com/te", "res/res1/res2", [{"q1", "qval1"}, {"q2", "qval2"}]).
	"http://www.example.com/te/res/res1/res2?q1=qval1&q2=qval2"

License

The KIVRA restclient library uses an MIT license. So go ahead and do what you want!

Lots of fun!

More Repositories

1

oauth2

Erlang Oauth2 implementation
Erlang
217
star
2

oauth2_client

Erlang OAuth2 Client
Erlang
71
star
3

giallo

Small and flexible web framework on top of Cowboy
Erlang
67
star
4

email

The Erlang Mail application or Email for short
Erlang
33
star
5

zerolog

Log transport that just works with zero effort.
JavaScript
31
star
6

oauth2_example

Example application for oauth2
Erlang
30
star
7

emagick

Wrapper for Graphics/ImageMagick command line tool.
Erlang
27
star
8

lager_loggly

Loggly backend for lager
Erlang
16
star
9

robotnik

Dr Robotnik web scraper robot factory
Erlang
15
star
10

jsonformat

A Erlang Logger Json Formatter - Structured Logging of Maps to JSON
Erlang
13
star
11

merlin

Erlang
12
star
12

giallo_session

Session Management for Giallo Web Framework
Erlang
10
star
13

money_laundry

πŸ’Έ Erlang Currency and money laundering functions
Erlang
9
star
14

id_token

Erlang application to easily handle ID tokens
Erlang
9
star
15

mechanus_fsm

Mechanus FSM
Erlang
9
star
16

sftp_utils

Erlang SFTP Utils
Erlang
9
star
17

greph

Erlang port of Prismatic's graph package.
Erlang
8
star
18

developer.kivra.com

API Documentation, etc
HTML
7
star
19

fluentd-erlang

Fluentd Erlang Client
Erlang
6
star
20

ehtmltopdf

Erlang wrapper for converting HTML to PDF
Erlang
6
star
21

raven-erlang

Erlang
5
star
22

ews

Erlang Web Services
Erlang
4
star
23

krakend-correlationid

KrakenD middleware for adding Correlation IDs to incoming requests
Go
3
star
24

kivra-api-errors

Kivra API Errors
Erlang
3
star
25

krakend-urlrewrite

KrakenD middleware to rewrite URLs
Go
3
star
26

giallo_examples

Giallo example applications
Erlang
3
star
27

lager_backends

Custom backends for lager
Erlang
2
star
28

angular-popup-service

Library for handling popup boxes in angular
CSS
2
star
29

krakend-sizelimit

KrakenD middleware to limit the size of incoming requests
Go
2
star
30

opentracing-erlang

Opentracing API in Erlang
Erlang
1
star
31

krakend-metalog

KrakenD log formatter and logger middleware
Go
1
star
32

fingerprint_key_store_sample

Kotlin
1
star
33

krakend-shadowproxy

KrakenD middleware for mirroring of proxy (no-op) requests
Go
1
star
34

context

Erlang Standard Context
Erlang
1
star