{"id":21004973,"url":"https://github.com/ploeh/furl","last_synced_at":"2025-05-15T01:33:17.356Z","repository":{"id":140859868,"uuid":"85203956","full_name":"ploeh/Furl","owner":"ploeh","description":"Interact with HTTP resources using F# scripting","archived":false,"fork":false,"pushed_at":"2017-03-17T07:08:45.000Z","size":4,"stargazers_count":77,"open_issues_count":1,"forks_count":6,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-03T01:51:07.624Z","etag":null,"topics":["fsharp","rest-client","scripting","testing"],"latest_commit_sha":null,"homepage":null,"language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ploeh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-16T14:17:31.000Z","updated_at":"2025-02-06T19:31:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"f6e939a3-d6b1-47d5-92b5-da77681b6140","html_url":"https://github.com/ploeh/Furl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ploeh%2FFurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ploeh%2FFurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ploeh%2FFurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ploeh%2FFurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ploeh","download_url":"https://codeload.github.com/ploeh/Furl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254256527,"owners_count":22040309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fsharp","rest-client","scripting","testing"],"created_at":"2024-11-19T08:38:43.230Z","updated_at":"2025-05-15T01:33:17.334Z","avatar_url":"https://github.com/ploeh.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Furl\nInteract with HTTP resources using F# scripting\n\nWhen 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.\n\n## Example\n\nImagine 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:\n\n```fsharp\n\u003e get \"http://localhost:56268/availability/2017/3/17\" [] |\u003e bodyText;;\n\u003e val it : string = \"{\"openings\":[{\"date\":\"2017-03-17\",\"seats\":10}]}\"\n```\n\n## Use\n\nFurl is a **single F# script file**, so you can load it into any FSI session and starting using it right away.\n\n## Contributions\n\nFurl 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](https://github.com/ploeh/Furl/issues).\n\nThe 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.\n\n# Using type providers\n\nOften, when interacting with REST APIs, you must either send JSON or XML, or you receive data in one of those formats.\n\nWith [F# Data](http://fsharp.github.io/FSharp.Data), you can use XML or JSON type providers to create even complex data structures, or to parse the responses you receive.\n\nIn order to use the XML or JSON type provider, you must first load *F# Data* in FSI:\n\n```fsharp\n\u003e #r @\".\\packages\\FSharp.Data\\lib\\net40\\FSharp.Data.dll\";;\n```\n\nWhen 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:\n\n```fsharp\nnamespace Ploeh.Samples.BookingApi.BoundaryTests\n\nopen FSharp.Data\n\ntype ReservationJson = JsonProvider\u003c\"\"\"\n{\n    \"date\": \"some date\",\n    \"name\": \"Mark Seemann\",\n    \"email\": \"mark@example.org\",\n    \"quantity\": 4\n}\"\"\"\u003e\n\ntype AvailabilityJson = JsonProvider\u003c\"\"\"\n{\n    \"openings\": [\n        {\n            \"date\": \"some date\",\n            \"seats\": 10\n        }\n    ]\n}\"\"\"\u003e\n```\n\nIf you have such a file, you can load it into your FSI session:\n\n```fsharp\n\u003e #load @\".\\BookingApi\\BookingApi.BoundaryTests\\ProvidedTypes.fs\";;\n```\n\nYou can now start your local development server and start interacting with your REST API:\n\n```fsharp\n\u003e let json = ReservationJson.Root (\"2017-03-18\", \"Mark Seemann\", \"mark@example.com\", 2) |\u003e string;;\n\u003e\nval json : string =\n  \"{\n  \"date\": \"2017-03-18\",\n  \"name\": \"Mark Seemann\",\n  \"ema\"+[44 chars]\n\n\u003e post \"http://localhost:56268/reservations\" [\"Content-Type\", \"application/json\"] json;;\n\u003e val it : HttpResponseMessage =\n  StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent,  \n```\n\nIn the above example, I've truncated the response, because it actually gives you a lot of data.\n\nIf you want to query a resource and parse the response, that's easy to do as well:\n\n```fsharp\n\u003e get \"http://localhost:56268/availability/2017/3/18\" [] |\u003e bodyText |\u003e AvailabilityJson.Parse;;\n\u003e val it : FSharp.Data.JsonProvider\u003c...\u003e.Root =\n  {\n  \"openings\": [\n    {\n      \"date\": \"2017-03-18\",\n      \"seats\": 8\n    }\n  ]\n}\n```\n\nThese 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.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fploeh%2Ffurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fploeh%2Ffurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fploeh%2Ffurl/lists"}