A Clojure client for Skroutz API (v3 and above). Please check the documentation for more information.
lein:
[clj_skroutz "0.0.1"]
-
:token-url The url to grab app tokens. Can be
https://www.skroutz.gr/oauth2/token
orhttps://www.alve.com/oauth2/token
. -
:scope The scope of client access. Check here for details.
-
:grant-type The grant type of oauth access. Can be
client_credentials
orauthorization_code
. -
:redirect-uri The redirect uri for callbacks.
-
:accept-header The accept header. Can be
application/vnd.skroutz+json;version=3
orapplication/vnd.alve+json;version=3
. -
:user-agent The user agent info.
-
:url The url to consume api calls. Can be
https://api.skroutz.gr/
orhttps://api.alve.com/
-
:client-id The client id. See here for details.
-
:client-secret The client secret. See here for details.
-
:app-token The generated app token.
-
:auth-prefix The authorization prefix. Must be
"Bearer "
-
:user-code The user code. See here for details.
To simplify working with multiple users or flavors (Skroutz, Alve, Scrooge) one can use
the macro with-profile
. Each profile should be a hashmap with the appropriate
configuration options.
(use 'clj_skroutz.core)
(require 'clj_skroutz.categories)
; Suppose we use carica for loading configs
(def skroutz-public (carica.core/config :skroutz-public))
(with-profile skroutz-public (clj_skroutz.categories/all))
Before proceed read documentation here.
- Application token:
Once you have client-id
and client-secret
:
(require 'clj_skroutz.oauth)
(use 'clj_skroutz.core)
(def my-profile {:redirect-uri "http://example.com/callback",
:grant-type "client_credentials", :client-id "your-client-id",
:user-agent "awesome client", :scope "public",
:token-url "https://www.skroutz.gr/oauth2/token",
:url "https://api.skroutz.gr/",
:accept-header "application/vnd.skroutz+json;version=3",
:client-secret "your-client-secret", :auth-prefix "Bearer "})
(with-profile my-profile (clj_skroutz.oauth/app-token))
You should see a response with an access-token
. Grab this token and you are
ready to consume Skroutz API v3.
- User token:
Once you get a user code:
(require 'clj_skroutz.oauth)
; Decodes user code
(def code (clj_skroutz.oauth/decode-user-code your-code-here))
; Continue from the previous example
(def my-profile (conj my-profile {:user-code code, :grant-type "authorization_code"}))
; Grab app token
(clj_skroutz.oauth/user-token code)
- Categories
; Continue from the previous examples
(require '[clj_skroutz.categories :as skroutz-categories])
; Gets specific category
(with-profile my-profle (skroutz-categories/category 40))
; Gets root
(with-profile my-profile (skroutz-categories/root))
; Lists skus for category
(with-profile my-profile (skroutz-categories/skus 40))
; Lists skus for categories with ordering
; Available orderings are `popularity` and `pricevat`
(with-profile my-profile (skroutz-categories/skus 40 [:order_by "popularity" :order_dir "desc"]))
Distributed under the Eclipse Public License, the same as Clojure.