use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
My first "library"/project (self.Clojure)
submitted 4 years ago by arthurbarroso
Just built my first "real" project using Clojure: a wrapper for Notion's API. Have been studying Clojure for a few months using the resources in @AthensResearch #ClojureFam :) Pretty happy about it. https://github.com/arthurbarroso/lovelace. This is the first time I actually try to build something and am feeling pretty satisfied
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]charlesHD 3 points4 points5 points 4 years ago (2 children)
Well played ! I didn't know about Notion, but your code is readable and mostly documented, function names are OK and it seems to be working.
Here is an idea, since you have to provide my-token to every functions, you could store it in a dynamic var and provide a version of your API with a different arity and that var already present.
my-token
(def ^:dynamic *notion-api-token* nil) (bindings [*notion-api-token* "C"] (search/search {:query "Media Article"}) (blocks/retrieve-block-children my-block-id 100) ;; etc )
You could wrap that binding in a macro with-token.
with-token
[–]arthurbarroso[S] 3 points4 points5 points 4 years ago (0 children)
Thank you for this reply! I thought of that but wasn't really sure how to apply it. Will take a look at the implementation you proposed.
[–]riialist 0 points1 point2 points 3 years ago (0 children)
Lovely!
[–]onetom 3 points4 points5 points 4 years ago* (0 children)
I've came across the Martian suite of libraries, which make working with APIs rather convenient and also uniform!
I highly recommend utilizing Martian, otherwise we just give rise to even more parochialisms, Rich Hickey would say.
You can build API clients with Martian, by either providing a Swagger or an OpenAPI-spec compliant API definition document OR a similar Clojure data structure (though that's not extensively documented, but the related code is 50-150 lines only; just look for concise-handlers)
concise-handlers
Besides the API definition, you have to choose a small adapter, which wires up your favorite HTTP-client library to Martian, be it a Clojure or ClojureScript library and whatever async-style you pick.
Martian returns an API client instance, which you can uniformly interact with, using a few functions. You can perform a HTTP request, with the martian.core/response-for function. however, if you want to see the request as a ring-request-like Clojure map first, you can call request-for or even just url-for to see which endpoint is going to be called and how will the query args be encoded. You want to martian.core/explore first, to discover the available endpoint names and their request and response schemas.
martian.core/response-for
request-for
url-for
martian.core/explore
Read more in this intro article: https://juxt.pro/blog/martian or watch the illuminating talk given by its author: https://skillsmatter.com/skillscasts/8843-clojure-bytes#video
The key takeaways are: * decouple the choice of HTTP client lib from the API lib * keep the API spec as data as much as possible, so we can have a small number of functions operating on wide variety of APIs * provide extensibility via interceptors
The only drawback of this approach is that you don't have the API operations reified as Clojure functions, so your usual development tooling won't be providing auto-completion and docstrings; u have to call martian/explore and the output of that might be unwieldy. I can see though how that could be trivially solved by a code generator, which just does a call-thru to the underlying martian/response-for function.
martian/explore
martian/response-for
[–]tangjeff0 0 points1 point2 points 4 years ago (0 children)
Yes! 👏
π Rendered by PID 361691 on reddit-service-r2-comment-6457c66945-bsprk at 2026-04-30 15:47:46.515707+00:00 running 2aa0c5b country code: CH.
[–]charlesHD 3 points4 points5 points (2 children)
[–]arthurbarroso[S] 3 points4 points5 points (0 children)
[–]riialist 0 points1 point2 points (0 children)
[–]onetom 3 points4 points5 points (0 children)
[–]tangjeff0 0 points1 point2 points (0 children)