fabric ·nu.http

Plug an HTTP API into Nu.

You need to talk to an HTTP API. Name the endpoints once and call them from your Nu program like anything else.

Powered byhttpx

Point Nu at your API.

List the endpoints you need. Give Nu the base URL. Now inside your Nu program, calling an endpoint hits the real API and hands the response back.

Start with the endpoints you already hit — GET this, POST that. Name them and give each one its path.

Hand Nu the base URL. That is the whole client — no request builder, no wrapper class per API.

Call an endpoint anywhere in the program. The response comes back parsed and ready for whatever comes next.

github.py
python · 12 locpy
import nu
class GitHub(nu.Service):
get_repo = nu.http.GETRef.method("/repos/{owner}/{repo}")
# call it like a function; kwargs fill the path and query
app = nu.With(
nu.http.bind(GitHub, base_url="https://api.github.com"),
body=nu.print(GitHub.get_repo(owner="nustackdev", repo="nu")),
)
nu.run(app)

What you get out of it.

A few things that fall out once your API speaks Nu.

One shape for every verb.

GET, POST, PUT, PATCH, DELETE all read the same in your code. No client class per API, no request builder to learn.

Sync or async, your call.

Write the program however you write it today. Nu runs sync programs and async programs the same way, and picks the right HTTP path underneath.

Plays with everything else.

A response is a normal Nu value the moment you get it. Feed it into a live UI, drop it in storage, or hand it to the next call.

Try Nu.

One command gets you the wheel with every fabric. Then follow the movies tutorial to build a real app in an afternoon.

01 Install

pip install "nustack-py[all]"

02 Run the demo

nu demo movies

03 Build your app

Browse examples

Like what you see?

The project is young. Star it, join the room, watch what we ship next.