neptune-backend: Neptune Client

[ bsd3, library, program, web ] [ Propose Tags ]

Client library for calling the Neptune API based on http-client.

Neptune Backend API API version: 2.8

OpenAPI version: 3.0.1

[Skip to Readme]


Manual Flags


Use the katip package to provide logging (if false, use the default monad-logger package)


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS] 0.1.1, 0.1.2, 0.2.1, 0.3.0
Dependencies aeson (>=1.0 && <2.0), base (>=4.7 && <5.0), base64-bytestring (>1.0 && <2.0), bytestring (>=0.10.0 && <0.11), case-insensitive, concurrent-extra (>=0.7 && <0.8), containers (>= && <0.8), deepseq (>=1.4 && <1.6), envy (>=2.0 && <2.1), exceptions (>=0.4), http-api-data (>=0.3.4 && <0.5), http-client (>=0.5 && <0.7), http-client-tls, http-media (>=0.4 && <0.9), http-types (>=0.8 && <0.13), iso8601-time (>=0.1.3 && <0.2.0), jwt (<1), katip (>=0.8 && <1.0), lens (>=4 && <5), lens-aeson (>=1 && <2), microlens (>=0.4.3 && <0.5), modern-uri (>=0.3 && <0.4), mtl (>=2.2.1), neptune-backend, network (>=2.6.2 && <3.9), random (>=1.1), req (>=3 && <4), retry (>=0.8 && <0.9), rio (>=0.1 && <0.2), safe-exceptions (<0.2), text (>=0.11 && <1.3), time (>=1.5), transformers (>=, unix (>=2.7 && <2.8), unordered-containers, uuid (>=1 && <2), vector (>=0.10.9 && <0.13), websockets (>=0.12 && <0.13), wuss (>=1 && <2) [details]
License BSD-3-Clause
Copyright 2020 - Jiasen Wu
Author Jiasen Wu
Category Web
Source repo head: git clone
Uploaded by JiasenWu at 2021-01-01T21:40:21Z
Distributions NixOS:0.3.0
Executables example-app
Downloads 245 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-01-01 [all 1 reports]

Readme for neptune-backend-0.3.0

[back to package description]

Neptune high-level API

main = do
    -- Experiment 'sandbox' must be created from the Neptune dashboard
    withNept "jiasen/sandbox" $ \_ experiment -> do
        forM_ [1..10::Int] $ \i -> do
            -- You can log arbitrary name/value (current limited to double values)
            nlog experiment "counter" (fromIntegral (i * i) :: Double)
            threadDelay 1000000


  • Support logging text, image value.
  • Create project
  • Support system channels
  • Get git information

OpenAPI Auto-Generated http-client Bindings to Neptune Backend API

This library is intended to be imported qualified.


NeptuneBackend.Client use the "dispatch" functions to send requests
NeptuneBackend.Core core funcions, config and request types
NeptuneBackend.API construct api requests
NeptuneBackend.Model describes api models
NeptuneBackend.MimeTypes encoding/decoding MIME types (content-types/accept)
NeptuneBackend.ModelLens lenses for model fields
NeptuneBackend.Logging logging functions and utils


This library adds type safety around what OpenAPI specifies as Produces and Consumes for each Operation (e.g. the list of MIME types an Operation can Produce (using 'accept' headers) and Consume (using 'content-type' headers).

For example, if there is an Operation named addFoo, there will be a data type generated named AddFoo (note the capitalization), which describes additional constraints and actions on the addFoo operation via its typeclass instances. These typeclass instances can be viewed in GHCi or via the Haddocks.

  • required parameters are included as function arguments to addFoo
  • optional non-body parameters are included by using applyOptionalParam
  • optional body parameters are set by using setBodyParam

Example code generated for pretend addFoo operation:

data AddFoo 	
instance Consumes AddFoo MimeJSON
instance Produces AddFoo MimeJSON
instance Produces AddFoo MimeXML
instance HasBodyParam AddFoo FooModel
instance HasOptionalParam AddFoo FooName
instance HasOptionalParam AddFoo FooId

this would indicate that:

  • the addFoo operation can consume JSON
  • the addFoo operation produces JSON or XML, depending on the argument passed to the dispatch function
  • the addFoo operation can set it's body param of FooModel via setBodyParam
  • the addFoo operation can set 2 different optional parameters via applyOptionalParam

If the OpenAPI spec doesn't declare it can accept or produce a certain MIME type for a given Operation, you should either add a Produces or Consumes instance for the desired MIME types (assuming the server supports it), use dispatchLbsUnsafe or modify the OpenAPI spec and run the generator again.

New MIME type instances can be added via MimeType/MimeRender/MimeUnrender

Only JSON instances are generated by default, and in some case x-www-form-urlencoded instances (FromFrom, ToForm) will also be generated if the model fields are primitive types, and there are Operations using x-www-form-urlencoded which use those models.


A haskell data type will be generated for each OpenAPI authentication type.

If for example the AuthMethod AuthOAuthFoo is generated for OAuth operations, then addAuthMethod should be used to add the AuthMethod config.

When a request is dispatched, if a matching auth method is found in the config, it will be applied to the request.


mgr <- newManager defaultManagerSettings
config0 <- withStdoutLogging =<< newConfig 
let config = config0
    `addAuthMethod` AuthOAuthFoo "secret-key"

let addFooRequest = 
    (ContentType MimeJSON) 
    (Accept MimeXML) 
    (ParamBar paramBar)
    (ParamQux paramQux)
  `applyOptionalParam` FooId 1
  `applyOptionalParam` FooName "name"
  `setHeader` [("qux_header","xxyy")]
addFooResult <- dispatchMime mgr config addFooRequest

See the example app and the haddocks for details.