FSharp.Data: Data Access Made Simple
The FSharp.Data package implements core functionality to access common data formats in your F# applications and scripts. It contains F# type providers for working with structured file formats (CSV, HTML, JSON and XML) and helpers for parsing CSV, HTML and JSON files and for sending HTTP requests.
This library focuses on providing simple access to the structured documents and other data sources.
FSharp.Data stems from Types from data Making structured data first-class citizens in F# by Petricek, Syme and Guerra. This paper received a Distinguished Paper award at PLDI 2016 and was selected as one of three CACM Research Highlight in 2018. 🏆🏆🏆
The package is available on NuGet.
Type Providers
The FSharp.Data type providers for CSV, HTML, JSON and XML infer types from the structure of a sample document (or a document containing multiple samples). The structure is then used to provide easy to use type-safe access to documents that follow the same structure.
- CSV Type Provider - discusses the
CsvProvider<..>
type - HTML Type Provider - discusses the
HtmlProvider<...>
type - JSON Type Provider - discusses the
JsonProvider<..>
type - XML Type Provider - discusses the
XmlProvider<..>
type
The package also contains a type provider for accessing data from the WorldBank.
Data Access Tools
The package contains functionality to simplify data access. In particular, it includes tools for HTTP web requests and CSV, HTML, and JSON parsers with simple dynamic API. For more information, see the following topics:
-
HTTP Utilities - discusses the
Http
type that can be used to send HTTP web requests. - CSV Parser - introduces the CSV parser (without using the type provider)
- HTML Parser - introduces the HTML parser (without using the type provider)
- JSON Parser - introduces the JSON parser (without using the type provider)
Tutorials
The following tutorials contain additional examples that use multiple features together:
-
Converting between JSON and XML - implements two serialization
functions that convert between the standard .NET
XElement
and theJsonValue
from FSharp.Data. The tutorial demonstrates pattern matching onJsonValue
. -
Anonymizing JSON - implements a function to anonymize a
JsonValue
from FSharp.Data. The tutorial demonstrates pattern matching onJsonValue
.
Below is a brief practical demonstration of using FSharp.Data:
Reference Documentation
There's also reference documentation available. Please note that everything under
the FSharp.Data.Runtime
namespace is not considered as part of the public API and can change without notice.
Contributing and license
The library is available under Apache 2.0. For more information see the License file in the GitHub repository. In summary, this means that you can use the library for commercial purposes, fork it, and modify it as you wish. FSharp.Data is made possible by the volunteer work of more than a dozen contributors and we're open to contributions from anyone. If you want to help out but don't know where to start, you can take one of the Up-For-Grabs issues, or help to improve the documentation.
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding new public API's, please also contribute samples to the docs.