I am creating a json API for my mobile clients and was wondering if there's already a standard like User-Agent to send information like
Or any other thing my server would like to know about the client device...
Since mobile usage has grown so popular, it seems reasonable if there was a standard of some sort.
User-Agent
header (even though the requests are not being sent by browsers) ?X-MyApp-...
?I know I can chose to use any of the methods I like since it's my api and I can decide whatever I want, but i'm curious if there's any industry standard in that matter.
Thanks
The HTTP headers User-Agent is a request header that allows a characteristic string that allows network protocol peers to identify the Operating System and Browser of the web-server.
General header is an outdated term used to refer to an HTTP header that can be used in both request and response messages, but which doesn't apply to the content itself (a header that applied to the content was called an entity header).
An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response. For example, a request message can use headers to indicate it's preferred media formats, while a response can use header to indicate the media format of the returned body.
There is no standard HTTP header for conveying device-specific information. I can't speak to what information the Android platform exposes, but I know that any iOS app that uses NSURLConnection to make HTTP requests uses a customised User-Agent string which is of the following format:
<App Name>/<App Version> CFNetwork/<CFNetwork version> Darwin/<kernel version>
There's a pretty handy list of CFNetwork versions that you could use to try to determine what version of iOS is running on the device making the calls. However, it's worth noting that sometimes the CFNetwork and kernel versions don't change between iOS releases. For example, CFNetwork/609.1.4 Darwin/13.0.0
is used by iOS 6.1.2, 6.1.3, and 6.1.4.
Your best bet is to define your own X-Header and transmit exactly the information you need. Prefixing the X-Header will reduce the likelihood of a header collision with another app, but since it's trivial to add a header to a request, you can't rule out spoofing or invalid data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With