Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active April 2, 2023 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/5de34df6e63f0ec797ead103603aa278 to your computer and use it in GitHub Desktop.
Save dacr/5de34df6e63f0ec797ead103603aa278 to your computer and use it in GitHub Desktop.
List a user github gists using sttp for client http and json4s for json processing. / published by https://github.com/dacr/code-examples-manager #a3d60a09-897a-450c-a1d5-e73e5bc4ded1/f2eb10df043f9f4d09d7b3abf741747bc1125a78
// summary : List a user github gists using sttp for client http and json4s for json processing.
// keywords : scala, sttp, json4s, json, gists-api
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : a3d60a09-897a-450c-a1d5-e73e5bc4ded1
// created-on : 2019-05-19T16:59:54Z
// managed-by : https://github.com/dacr/code-examples-manager
// execution : scala 2.12 ammonite script (http://ammonite.io/) - run as follow 'amm scriptname.sc'
import $ivy.`com.softwaremill.sttp::core:1.5.17`
import $ivy.`com.softwaremill.sttp::json4s:1.5.17`
import $ivy.`org.json4s::json4s-native:3.6.5`
import com.softwaremill.sttp.quick._
import com.softwaremill.sttp.json4s._
case class Gist(
id:String,
description:String,
html_url:String,
)
implicit val serialization = org.json4s.native.Serialization
implicit val formats = org.json4s.DefaultFormats
val gists =sttp.get(uri"https://api.github.com/users/dacr/gists").response(asJson[Array[Gist]]).send()
gists.body.right.get.foreach{ println }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment