Akka HTTP integration
scala
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.stream.ActorMaterializer
import scala.concurrent.Future
import scala.util.{Failure, Success}
object HttpClientExample extends App {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
import system.dispatcher
val url = "https://api.apitube.io/v1/news/everything?limit=50&api_key=YOUR_API_KEY"
val responseFuture: Future[HttpResponse] = Http().singleRequest(HttpRequest(uri = url))
responseFuture.onComplete {
case Success(res) =>
res.entity.dataBytes.runFold("")(_ ++ _.utf8String).foreach(println)
case Failure(_) => sys.error("Error")
}
}