All Projects → ploeh → Furl

ploeh / Furl

Licence: mit
Interact with HTTP resources using F# scripting

Programming Languages

fsharp
127 projects
scripting
82 projects

Projects that are alternatives of or similar to Furl

Vial Http
Simple http rest tool for vim
Stars: ✭ 412 (+449.33%)
Mutual labels:  rest-client
Farwest
Framework for building RESTful HATEOAS-driven applications.
Stars: ✭ 18 (-76%)
Mutual labels:  rest-client
Github3.py
Hi, I'm a library for interacting with GItHub's REST API in a convenient and ergonomic way. I work on Python 3.6+.
Stars: ✭ 1,029 (+1272%)
Mutual labels:  rest-client
Datafire
A framework for building integrations and APIs
Stars: ✭ 487 (+549.33%)
Mutual labels:  rest-client
Everest
A beautiful, cross-platform REST client.
Stars: ✭ 785 (+946.67%)
Mutual labels:  rest-client
Yet Another Rest Client
YARC (Yet Another REST Client) is an easy-to-use REST Client for Google Chrome.
Stars: ✭ 23 (-69.33%)
Mutual labels:  rest-client
Restc Cpp
Modern C++ REST Client library
Stars: ✭ 371 (+394.67%)
Mutual labels:  rest-client
Rest Client
A tool for automated testing REST API, generating exquisite testing report and REST API documentation.
Stars: ✭ 1,181 (+1474.67%)
Mutual labels:  rest-client
Ngx Restangular
Restangular for Angular 2 and higher versions
Stars: ✭ 787 (+949.33%)
Mutual labels:  rest-client
Laravel Compass
A REST client inside your Laravel app
Stars: ✭ 1,002 (+1236%)
Mutual labels:  rest-client
React Fetching Library
Simple and powerful API client for react 👍 Use hooks or FACCs to fetch data in easy way. No dependencies! Just react under the hood.
Stars: ✭ 561 (+648%)
Mutual labels:  rest-client
Varest
REST API plugin for Unreal Engine 4 - we love restfull backend and JSON communications!
Stars: ✭ 707 (+842.67%)
Mutual labels:  rest-client
Gwasrapidd
gwasrapidd: an R package to query, download and wrangle GWAS Catalog data
Stars: ✭ 28 (-62.67%)
Mutual labels:  rest-client
Resty
Simple HTTP and REST client library for Go
Stars: ✭ 5,368 (+7057.33%)
Mutual labels:  rest-client
Apiclientcodegen
A collection of Visual Studio custom tool code generators for Swagger / OpenAPI specification files
Stars: ✭ 50 (-33.33%)
Mutual labels:  rest-client
Udash Core
Scala framework for building beautiful and maintainable web applications.
Stars: ✭ 405 (+440%)
Mutual labels:  rest-client
Hoodie
Hoodie is a type safe wrapper around jersey http client
Stars: ✭ 22 (-70.67%)
Mutual labels:  rest-client
Fluentlyhttpclient
Http Client for .NET Standard with fluent APIs which are intuitive, easy to use and also highly extensible.
Stars: ✭ 73 (-2.67%)
Mutual labels:  rest-client
Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+14078.67%)
Mutual labels:  rest-client
Apipie
Transform api declaration to js object for frontend. Inspired by VueRouter, koa-middleware and axios.
Stars: ✭ 29 (-61.33%)
Mutual labels:  rest-client

Furl

Interact with HTTP resources using F# scripting

When developing REST APIs, you often need to test or verify them in various ad hoc manners. You could use cURL, but if you're more familiar with F# than Bash scripting, you can use Furl instead. This will also enable you to leverage JSON or XML type providers in your scripts or exploratory tests.

Example

Imagine that you have an HTTP API that exposes resources for making restaurant reservations. For example, if you want to know how many free seats are available for a particular date, you can perform a simple GET request:

> get "http://localhost:56268/availability/2017/3/17" [] |> bodyText;;
> val it : string = "{"openings":[{"date":"2017-03-17","seats":10}]}"

Use

Furl is a single F# script file, so you can load it into any FSI session and starting using it right away.

Contributions

Furl has exactly the features I've needed so far. For the last half a year, I've only needed to do GET and POST HTTP requests, so those are the only HTTP methods available. If you need more features, please send a pull request, or open an issue.

The philosophy behind Furl is to keep it simple and in a single file. Its purpose is to support exploratory testing, not to address every possible use case ever.

Using type providers

Often, when interacting with REST APIs, you must either send JSON or XML, or you receive data in one of those formats.

With F# Data, you can use XML or JSON type providers to create even complex data structures, or to parse the responses you receive.

In order to use the XML or JSON type provider, you must first load F# Data in FSI:

> #r @".\packages\FSharp.Data\lib\net40\FSharp.Data.dll";;

When I develop REST APIs, I often write integration tests in F#. In such tests, I define the data formats in a stand-alone file, so that it's easy to load into FSI. Here's an example:

namespace Ploeh.Samples.BookingApi.BoundaryTests

open FSharp.Data

type ReservationJson = JsonProvider<"""
{
    "date": "some date",
    "name": "Mark Seemann",
    "email": "mark@example.org",
    "quantity": 4
}""">

type AvailabilityJson = JsonProvider<"""
{
    "openings": [
        {
            "date": "some date",
            "seats": 10
        }
    ]
}""">

If you have such a file, you can load it into your FSI session:

> #load @".\BookingApi\BookingApi.BoundaryTests\ProvidedTypes.fs";;

You can now start your local development server and start interacting with your REST API:

> let json = ReservationJson.Root ("2017-03-18", "Mark Seemann", "[email protected]", 2) |> string;;
>
val json : string =
  "{
  "date": "2017-03-18",
  "name": "Mark Seemann",
  "ema"+[44 chars]

> post "http://localhost:56268/reservations" ["Content-Type", "application/json"] json;;
> val it : HttpResponseMessage =
  StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent,  

In the above example, I've truncated the response, because it actually gives you a lot of data.

If you want to query a resource and parse the response, that's easy to do as well:

> get "http://localhost:56268/availability/2017/3/18" [] |> bodyText |> AvailabilityJson.Parse;;
> val it : FSharp.Data.JsonProvider<...>.Root =
  {
  "openings": [
    {
      "date": "2017-03-18",
      "seats": 8
    }
  ]
}

These examples demonstrate how to interact with a local development server, but Furl can be used to interact with any HTTP-based API on your network, including the internet.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].