Kode 49 Posted July 10, 2014 Share Posted July 10, 2014 To any devs, if you use the default JSON feed can you change it to use http://webservice.fanart.tv/v3/movies/MOVIEID?api_key=YOURAPIKEY So for example: http://webservice.fanart.tv/v3/movies/tt0120737?api_key=6fa42b0ef3b5f3aab6a7edaa78675ac2 The new API isn't finished yet, but works a lot better in the backend, is less stressful on the server, and uses much less bandwidth, the GET endpoint for movies wont change so it should be safe to use. The reason for this request before its finished is API traffic has gone from about 2.6million requests a day (76million a month) to around 7.6million a day (or about 230million a month) in the last month, and the API server is struggling at times, so anyone we can move over to the newer API will be a help. Link to comment Share on other sites More sharing options...
Luke 37022 Posted July 10, 2014 Share Posted July 10, 2014 we're actually using the xml still. is that an issue? while I have you here, the reason we're still using the xml is due to the json strcuture which cannot be easily parsed by generic json parsing libraries. for example: "The Lord of the Rings: The Fellowship of the Ring": {} using the movie name as the property name means we can't define a known structure, which means we're going to have to write our own code to parse this. whereas something like this would be much easier to parse with very little effort: { "name": "The Lord of the Rings: The Fellowship of the Ring" } So while we can use your json, it's just not very developer friendly which means I'm going to have to allocate more time to it than I would like. Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 (edited) XML isn't in the new API (yet, not 100% whether to add it yet, might keep just in the v2 api) As for JSON, really? Im not sure what parser you are using but it shouldn't be that difficult, the name is just for reference but the rest should be readily accessible, in PHP you could just do something like: $request = file_get_contents("http://webservice.fanart.tv/v3/movies/tt0120737?api_key=6fa42b0ef3b5f3aab6a7edaa78675ac2"); $art = json_decode($request); $movie = current($art); then everything is accessible from $movie->itemname so foreach($movie->clearlogos as $clearlogo) { do something } The biggest issue with changing it is it will mean everyone who currently uses it will have to change their code as well as the url Edited July 10, 2014 by Kode Link to comment Share on other sites More sharing options...
ebr 14904 Posted July 11, 2014 Share Posted July 11, 2014 The problem is we're not dealing in PHP we are in managed .net (c#) so we need defined property names or we cannot define a c# class that matches up with your json. Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 In case anyone is interested here are the ab results on the same server OLD API Concurrency Level: 5 Time taken for tests: 343.424 seconds Complete requests: 1000 Total transferred: 12221000 bytes HTML transferred: 11789000 bytes Requests per second: 2.91 [#/sec] (mean) Time per request: 1717.118 [ms] (mean) Time per request: 343.424 [ms] (mean, across all concurrent requests) Transfer rate: 34.75 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 4 Processing: 188 1712 454.1 1802 2605 Waiting: 166 1656 450.7 1745 2558 Total: 188 1712 454.1 1803 2606 Percentage of the requests served within a certain time (ms) 50% 1803 66% 1954 75% 2023 80% 2056 90% 2179 95% 2286 98% 2404 99% 2470 100% 2606 (longest request) NEW API Concurrency Level: 5 Time taken for tests: 3.185 seconds Complete requests: 1000 Total transferred: 17474000 bytes HTML transferred: 17294000 bytes Requests per second: 313.97 [#/sec] (mean) Time per request: 15.925 [ms] (mean) Time per request: 3.185 [ms] (mean, across all concurrent requests) Transfer rate: 5357.74 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.1 0 1 Processing: 9 16 9.1 11 65 Waiting: 2 7 7.8 4 55 Total: 9 16 9.1 12 65 Percentage of the requests served within a certain time (ms) 50% 12 66% 15 75% 18 80% 20 90% 27 95% 36 98% 46 99% 51 100% 65 (longest request) 1 Link to comment Share on other sites More sharing options...
Luke 37022 Posted July 11, 2014 Share Posted July 11, 2014 Yea. it can be done, but it will take longer than usual. whereas Tmdb for example, I added them in about 15 minutes the other day with their easy to parse structure. Link to comment Share on other sites More sharing options...
Luke 37022 Posted July 11, 2014 Share Posted July 11, 2014 nice work. those look like some great improvements. Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 Does this help at all? http://stackoverflow.com/questions/17454055/dealing-with-fanart-tv-webservice-response-json-and-c-sharp Link to comment Share on other sites More sharing options...
Tim Hobbs 91 Posted July 11, 2014 Share Posted July 11, 2014 Would dynamic help out here? It may make it easier with a little less hoop-jumping. Even so, it would be in the best interest of a good api design for the fanart api to structure it similar to the above example Luke provided. You'll run in to similar issues with any statically typed language. Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 To be honest though, noone is using it yet, so I guess I could change it and hope devs update their code Link to comment Share on other sites More sharing options...
Tim Hobbs 91 Posted July 11, 2014 Share Posted July 11, 2014 (edited) Does this help at all? http://stackoverflow.com/questions/17454055/dealing-with-fanart-tv-webservice-response-json-and-c-sharp That is pretty good. I think it is probably just a preference to not have to use the Dictionary<string, *>. If there was a key passed via the API it could be deserialized directly to a typed object. At this point it is 6 of one, a half dozen of the other. It has been some time since I have done anything with java, and I know there is some generic support, but like I mentioned this may be an issue there too. Although, if it means breaking existing working code, I can understand why you'd maybe want to not change the API. Edited July 10, 2014 by Tim Hobbs Link to comment Share on other sites More sharing options...
ebr 14904 Posted July 11, 2014 Share Posted July 11, 2014 We could always write some custom code like that but, right now, we're using standard json deserializers and they won't understand the current structure. So, we'd always have to have a special case just for this API. Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 http://webservice.fanart.tv/v3/movies/120?api_key=6fa42b0ef3b5f3aab6a7edaa78675ac2 <-- that better? Link to comment Share on other sites More sharing options...
Luke 37022 Posted July 11, 2014 Share Posted July 11, 2014 Does this help at all? http://stackoverflow.com/questions/17454055/dealing-with-fanart-tv-webservice-response-json-and-c-sharp Thanks. I know how to do it, but just like what we've seen with our api, if you make it a priority to make it as easy as possible, you'll be surprised at the positive impact that will have. Link to comment Share on other sites More sharing options...
Luke 37022 Posted July 11, 2014 Share Posted July 11, 2014 http://webservice.fanart.tv/v3/movies/120?api_key=6fa42b0ef3b5f3aab6a7edaa78675ac2 how about http://paste2.org/e0XPZz9Z I'm missing a comma but you get the idea Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 would have movie in there make it easier for you? Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 You might not have got the right one as it was cched on one of the servers Link to comment Share on other sites More sharing options...
Luke 37022 Posted July 11, 2014 Share Posted July 11, 2014 ah ok, just saw the update. movie is not necessary. i only based that on what i saw previously. Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 http://webservice.fanart.tv/v3/movies/76338?api_key=6fa42b0ef3b5f3aab6a7edaa78675ac2 Link to comment Share on other sites More sharing options...
Luke 37022 Posted July 11, 2014 Share Posted July 11, 2014 http://webservice.fanart.tv/v3/movies/76338?api_key=6fa42b0ef3b5f3aab6a7edaa78675ac2 perfect Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 So does that work better for you guys like that? If so I'll leave it like that and tell people to update their code or stick with the old one for now Link to comment Share on other sites More sharing options...
Luke 37022 Posted July 11, 2014 Share Posted July 11, 2014 that will work better not only for us, but everyone who uses the api. no doubt about it. thanks. Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 No problem, it was useful to get feedback like this Link to comment Share on other sites More sharing options...
ScottIsAFool 517 Posted July 11, 2014 Share Posted July 11, 2014 (edited) Guess I should be ready to update this project then https://github.com/ScottIsAFool/FanArtPortable/ Also, this is how I got round the json problem with the older API (if anyone is interested) https://github.com/ScottIsAFool/FanArtPortable/blob/658d78e1bad4f861146bc32906c31591813eb4e1/FanArtPortable/ExtensionMethods.cs#L19 (usage: https://github.com/ScottIsAFool/FanArtPortable/blob/master/FanArtPortable/FanArtClient.cs#L174) Edited July 11, 2014 by ScottIsAFool 1 Link to comment Share on other sites More sharing options...
Kode 49 Posted July 11, 2014 Author Share Posted July 11, 2014 Nice Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now