Giter Site home page Giter Site logo

api list about martian HOT 7 CLOSED

awb99 avatar awb99 commented on May 20, 2024
api list

from martian.

Comments (7)

oliyh avatar oliyh commented on May 20, 2024

Hello,

Thank you for your kind words! There are already lists like https://github.com/public-apis/public-apis so I wouldn't be surprised if someone had already done it, needs a bit of searching however. Probably makes sense as its own list, and I would be happy to link to it from martian documentation.

Cheers

from martian.

awb99 avatar awb99 commented on May 20, 2024

I have written a library that can be used to authorize apis that need oauth2 tokens. I am currently converting the rest apis to martian. I have implemented github google xero. I will post a link once I am done converting.

from martian.

awb99 avatar awb99 commented on May 20, 2024

Some comments after using martian for a few days:

  1. It is hard to find out if a rest api supports discovery with swagger/openid. This is not that something is mentioned in most api documents that i found.

  2. Many openid connect providers have discoverable apis. Are they the same as openid/swagger specs? Seems to be a differwnt standard.. But perhaps it is the same?

  3. When specing an api it would be nice to have a way to make requests when all specs are just s/Any and then infer the specs from actual api requests. I guess we could write an interceptor that does that.

  4. Is it possible to have the api specs in edn files? This would make them more extendable. Also we could create a spec from a discoverable api endpoint once and then save it to edn. This way it can be easily extended at runtime.

from martian.

awb99 avatar awb99 commented on May 20, 2024

rest apis that work with oauth2 and martian: https://github.com/pink-gorilla/webly/tree/master/oauth2/src/modular/rest/martian
supports google, github, xero.

examples how to use the rest calls:
https://github.com/pink-gorilla/webly/tree/master/demo-rest/src/rest

What I dont like so much:
https://github.com/pink-gorilla/webly/blob/master/demo-rest/src/rest/google.clj
google has multiple api endpoint roots. I did add 3 google related martian "connection" exports.
They use the same oauth token store. But they just have different endpoint roots.

the xero web api uses two custom header interceptors (on top of the oauth token header).
a tenant-id header, which I create once (sort of a company with which to work). This works niceyl.
But then the query-api allows to search for changed data since a date. And for this interceptor
I did not manage to use a field from the request call.
https://github.com/pink-gorilla/webly/blob/master/oauth2/src/modular/rest/martian/xero.clj

from martian.

awb99 avatar awb99 commented on May 20, 2024

How can I rewrite this header-interceptor so that it
sets the "If-Modified-Since" header based on a parameter :modified-since

 (->> (martian/response-for t :invoice-list-since 
                                   {:modified-since "2022-01-01T00:00:00"
                                    :where "(Type == \"ACCREC\")"       
                                    :page 1})
            :body
            :Invoices
            print-invoices)

(defn add-modified-since-header [dt]
  {:name ::add-modified-since-header
   :enter (fn [ctx]
            (assoc-in ctx
                      [:request :headers "If-Modified-Since"]
                      dt))})

 {:route-name :invoice-list-since
    :summary "list invoices modified-since"
    :method :get
    :path-parts ["/api.xro/2.0/Invoices/"]
    :query-schema {s/Any s/Any}
    :produces ["application/json"]
    :consumes ["application/json"]
    :interceptors [(add-modified-since-header "2022-01-01T00:00:00")]}

from martian.

awb99 avatar awb99 commented on May 20, 2024

Any idea on my interceptor issue? Thanks

from martian.

oliyh avatar oliyh commented on May 20, 2024

Hi,

The ctx contains a key :params which contain the parameters passed to the martian call. You can use that to find your :modified-since value.

e.g.

(def add-modified-since-header
  {:name ::add-modified-since-header
   :enter (fn [ctx]
            (assoc-in ctx
                      [:request :headers "If-Modified-Since"]
                      (get-in ctx [:params :modified-since])))})

We have strayed a bit from the original issue topic of api lists, I will close this issue but feel free to open another one to deal with a particular topic, thanks for your feedback.

Cheers

from martian.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.