GRequest alternatives and similar libraries
Based on the "Network" category.
Alternatively, view GRequest alternatives based on common mentions on social networks and blogs.
-
Perfect
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and moreβ¦) -
SwiftSoup
SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS) -
Zewo
Lightweight library for web server applications in Swift on macOS and Linux powered by coroutines. -
BlueSocket
Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux. -
Connectivity
π Makes Internet connectivity detection more robust by detecting Wi-Fi networks without Internet access. -
WKZombie
WKZombie is a Swift framework for iOS/OSX to navigate within websites and collect data without the need of User Interface or API, also known as Headless browser. It can be used to run automated tests / snapshots and manipulate websites using Javascript. -
PeerKit
An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps -
Digger
Digger is a lightweight download framework that requires only one line of code to complete the file download task -
SOAPEngine
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app. -
BigBrother
DISCONTINUED. Automatically sets the network activity indicator for any performed request.
WorkOS - The modern identity platform for B2B SaaS
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of GRequest or a related project?
README
GRequest
An HTTP request library written in Swift.
Basic Usage
Be simple, as it should be:
Request("https://api.github.com/repos/lingoer/SwiftyJSON/issues").get{
response in
println(response.content)//HTTP Body as NSData
}
If you need more infomation:
Request("https://api.github.com/repos/lingoer/SwiftyJSON/issues").get{
response in
println(response.headers)
println(response.MIMEType)
println(response.statusCode)
println(response.encoding)
println(response.error)
println(response.content)//HTTP Body as NSData
println(response.string)//HTTP Body as String
println(response.object)//HTTP Body as Deserialized Custom Object, Default is NSData. See Below for more info
}
Use .query()
to pass parameters for GET methods
Request("www.example.com/api").query(["labels":"discuss"]).get{
response in
}
As for POST:
//This will encode body as application/x-www-form-urlencoded
Request("http://www.example.com").formBody(["key":"value"]).post{
response in
}
//This will encode body as application/json
Request("http://www.example.com").jsonBody(["key":"value"]).post{
response in
}
//You can custom your HTTP Body to POST, with Content-Type provided after it.
Request("http://www.example.com").body(customBodyData, typeString:"application/json; charset=utf-8").post{
response in
}
More:
Request("http://www.example.com").head{
response in
}
Request("http://www.example.com").put{
response in
}
Request("http://www.example.com").delete{
response in
}
Request("http://www.example.com").patch{
response in
}
Instances And Chainnings
A Request is in fact a GRequest<T>
It's typealias Request = GRequest<NSData>
as default.
And a GRequest
is a Generic class specifiying the behavior of the response.
Most methods returns an instance of the GRequest
to make chains.
For example .path()
:
Request("https://api.github.com").path("/repos/lingoer/SwiftyJSON/issues").get{
response in
}
Response Deserialization
As for the response behavior.
It's mostly about Response Deserialization:
Request("https://api.github.com/repos/lingoer/SwiftyJSON/issues").query(["labels":"discuss"]).get{
(response:GResponse<JSONValue>) in
println(response.object)//It's JSON Now
}
Note for more infomation about the JSONValue
, see SwiftyJSON
If you need something.Just specify it!
Request("https://www.google.com/images/srpr/logo11w.png").get{
(response:GResponse<UIImage>) in
let image:UIImage = response.object!
}
If you don't want to do that every time:
let client = GRequest<JSONValue>("http://api.example.com")
client.path("/path/to/resource").get{
response in
println(response.object) //Its JSON Now
}
Extensibility
You can add your custom implementation of your Model deserialization.
By extentions conform protocol: ResponseDeserialization
extension CustomModel:ResponseDeserialization{
class func convertFromData(data:NSData!) -> (CustomModel?, NSError?)
}
GRequest<CustomModel>("http://api.example.com").get{
response in
let model:CustomModel! = response.object
}