• Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by dkurok

  1. Not sure because I do it in a complete different env (C#). But I think (based on other examples I've seen for npm request) that your Authorization-header must be like this: let options = { url: `${setNum}/parts/?page=1&page_size=10`, json: true, headers: { 'Accept': 'application/json', Authorization: 'key ' + process.env.rebrickableApiKey } } So it seems that Authorization is treated as a special kind of header in NPM request (se for example here : Maybe that helps...
  2. I can confirm that it works now! Many thanks!
  3. The API-testpage under does not return any data. Neither for simple (non-authenticated) lego-functions nor for user-related ones. It seems that the page tries to call a http-URL instead of https (see Curl or Request URL). So simple API-requests like just return "error": "no response from server" Using https from my own client works; also requests with curl (under Windows) works (I xxx'ed out my key): curl -X GET --header "Authorization: key xxxxxxxxxx" "" returns: ... {"count":1,"next":null,"previous":null,"results":[{"part_num":"3001","name":"Brick 2 x 4","part_cat_id":11,"part_url":"","part_img_url":"","external_ids":{"BrickOwl":["771344"],"LEGO":["15589","54534","72841"]}}]} but using http instead: curl -X GET --header "Authorization: key xxxxxxxxxx" "" -v returns: * Trying 2606:4700:20::6818:1968... * connect to 2606:4700:20::6818:1968 port 80 failed: Network unreachable * Trying 2606:4700:20::6818:1a68... * connect to 2606:4700:20::6818:1a68 port 80 failed: Network unreachable * Trying * Connected to ( port 80 (#0) > GET /api/v3/lego/parts/?part_num=3001 HTTP/1.1 > Host: > User-Agent: curl/7.42.1 > Accept: */* > Authorization: key xxxxxxxxx > < HTTP/1.1 301 Moved Permanently < Date: Tue, 19 Feb 2019 14:17:59 GMT < Transfer-Encoding: chunked < Connection: keep-alive < Cache-Control: max-age=3600 < Expires: Tue, 19 Feb 2019 15:17:59 GMT < Location: < Server: cloudflare < CF-RAY: 4ab95c322d7c96e8-FRA < * Connection #0 to host left intact
  4. HangryDave, I had the same problem (also remarked in your mentioned thread from feanferr) and I can only recommend to ALWAYS inspect the value of the "next"-field in the JSON-result: { "count": 263, "next": "", "previous": null, "results": [ {... It is possible, even if you use page-size of 1000, that the API doesn't return you 1000 but for example only 100 (it's per configuration and depends on performance and can even be changing dynamically). So to receive the complete result you've got to call the url given by next (if it isn't null) and collect the results until you have next == null. This is the nearly the only way to determine that you've got the full result. And because this is valid for nearly all GET-API-methods, you should try to handle it in general on all your API-GET-calls. The other way to determine is to count your number of results received (the count of elements in result-array) and compare that to the number given in the "count"-field at the beginning. And then you can use next-URL to receive the next page.
  5. As Dragma explained you can use the page_size-parameter. But you should also look into the thread in this forum. Nathan explained that the standard page-size has been lowered to 100 and 1000 is the maximum you can give it in a call. In case your set has more than 1000 parts (unique in part_num and color; is there a set like this?) you have to use the next page URL given by the response-field named "next" in the very beginning of the response. If you want to fill a list or alike in a program/app, you can collect all results by calling first the API-function and then call the URL given by "next" until "next" is null. By this way you are not depending on changes in the defaults Nathan may change from time to time due to performance or other reasons.
  6. since a few weeks there are no more images in new MOC-notifications for followed designers (they are in the emails for general new MOC-emails). Can you bring them back; it makes it much easier to decide whether to open Rebrickable form the email or not; the title of a MOC isn't always that "speaking".
  7. Hi Dragma, I guess that {mykey} will really be replaced with your API-key here and you've used the {myKey}-notation just for clearing out your real key. If not, there may be a problem here. At the end of the day when going over the wire, post-data key-valuepairs have to be separated by a "&" and not ",". Otherwise the comma will be part of the password and this breaks your authorization (which explains the 403 - Not authorized) Maybe it helps Dietmar
  8. dkurok

    throttle in API

    Hi Simon, yes, some more information in download-files which are updated on a regular base (should be determined by the frquency of part/set-updates and alike by Nathan) would be very nice. Best regards Dietmar
  9. dkurok

    throttle in API

    Hi biodreamer, just a question about your explanation / clarification: Are you involved in the development of the Rebrickable-API? Or in other words: Do you KNOW for sure that the 28 calls with big chunks are better than the 5000 small calls? In terms of general thoughts I would agree, but the answer for a concrete system like RB depends on a lot of factors (like available bandwith, number of concurrent connections, DB-cache, memory, CPUs,...). So I can imagine a system where the answer would be the oposite (for example good scaling DB with huge cache having all queries for concrete part in cache but small bandwith to the outside world).
  10. dkurok

    throttle in API

    Hi biodreamer, thank you for the explanation! I'm just working on that aspects. I fetch data and cache them in my local DB, but from time to time I've got to consolidate and this is what I actually work on. So knowing that number of calls is more of a problem than "big" chunks on backend-side it good to know. BTW: It seems that pagesize greater 1000 in /api/v3/lego/parts are ignored. Otherwise I could fetch all parts in just two calls: first to get the first 1000 and the count; second to get all in one call using the count of the first call as the pagesize for the second call. But this does not work.... Is that by intention?
  11. Didn't expect to find it! Just wanted to point to the behavior of Firefox, which tells something about "corrupted content". So it seams that in some way Rebrickable returns something "malformed" and actually Firefox treats security issues very strict...
  12. Maybe not directly related to API: When searching in Bricklink for a part which not exists in Rebrickable (for example 42601pb01) and then clicking on the Rebrickable-link on the bricklink-site, an error is thrown in Firefox (57.0.4 (64-bit) on Windows 10): "Corrupted Content Error The site at has experienced a network protocol violation that cannot be repaired. The page you are trying to view cannot be shown because an error in the data transmission was detected. Please contact the website owners to inform them of this problem." Using IE or Edge, a Rebrickable-hosted page with a 404-error (Not found) is shown. I tried to understand what problem Firefox has with the page (by using F12 developer tools) and it states something with wrong usage of certificate. But I don't really understand. Not a big problem, but somehow "strange"...
  13. dkurok

    throttle in API

    Hi Nathan, thank you for explanation! Is the number of calls the bigger problem than the calls with big results? So as a (real) example: What is better for your API's infrastructure: A) 28 calls to /api/v3/lego/parts for getting all the actual 27651 parts (with 1000 parts returned in each call) OR ~5000 calls to /api/v3/lego/parts/{part_num} each receiving information for one part? If option A) is better for the infrastructure / performance / ..., could you just add year-from, year_to, [prints}, [molds] and [alternates] of the parts into the results-object of each part returned by /api/v3/lego/parts? This would reduce my number of calls dramatically... Many thanks Dietmar
  14. dkurok

    throttle in API

    I do exactly that in first place; but I also need the Bricklink-IDs, thumbnail_urls, molds, printed,... and so on and so I've got to call API on every part (i own) again (even the content from get /api/v3/lego/parts don't give back the needed fields). The download-files only have basic data...
  15. dkurok

    throttle in API

    Is there a way to get rid of the throttle in API-calls (Status code 429) or get it significantly higher. Actually there is a limit of 2 calls / second. I'm working on a (private; non-commercial) inventory-solution in C#/WPF and I have a database with ~50.000 parts for which I want to update part-information by using RB-API (I also write back my infomration into my RB-account). With a limit of 2 calls/second and handling the 429-status it will take ~7 hours. I think without throttle I could do it in ~2 hours. In the API-documentation it is stated: What is the meaning of "normal user"? How can I become a non-normal user? Best regards Dietmar
  16. dkurok

    api with google doc

    Can you explain a use-case you want to archive? It should be possible because (AFAIK) scripting in Google Sheet is more or less pure JavaScript and the Rebrickable API can be called also by JavaScript. But what do you want it to do in a sheet? I did a full Swagger-documenation (with modelling of the results) of the complete Rebrickable-API. And by using Swaggger-codegen one can also generate a JavaScript-Client-library from it. I'm using it for my private C# / WPF application for an inventory of all my sets and loose parts...
  17. Nathan, thank you for the information!
  18. The API-function /api/v3/users/{user_token}/parts/ has a query-parameter named "search". Has someone investigated how this parameter can be used ? Does it understand wildcards? For what kind of search (and on which fields) is it used? Same parameter also exists for /api/v3/users/{user_token}/sets/ How does it work there / can it be used there? Many thanks!
  19. Hello, I'm struggling with the API-function /api/v3/lego/sets/{set_num}/sets/ The explanation for this function in the API-documentation / Swagger is: "Get a list of all Inventory Sets in this Set." But what are "Inventory Sets" for a given Set? Can someone give me an example set-number which returns a non-empty result? MAybe I understand by that... Many thanks for help
  20. I try to delete a set from a custom list (my list is named "Sets I like to have"). I push the "Edit"-button and then I try "Delete"-button (see capture1.jpg) . The dialog stays open and a toast-message is shown with "Error 404: Not found" (see capture2.jpg). I can repeat clicking the Delete-button and it generates the error-message/notification again and again. Closing the dialog leaves the set as it is. Setting quantity to 0 (workaround for deletion) is not allowed. Can you help with that? regards Dietmar
  21. Hello Nathan, I've send you a forum-message with my swagger-file. regards Dietmar
  22. When clicking on a part in the "My Lost Parts" overview, the window with the "Part Summary" is opened. In this situation it would be nice if it has the "My Lost Parts" tab activated per default (and not the "Add this part to list/inventory" tab. I want to see in which set(s) the part is missing on the first view. Best regards Dietmar
  23. Great! I just tested it and now I think I understand what it returns. Am I right with the following? : A tupple (LEGO-design-id , LEGO-Color-ID) is mapped equivalent (in the meaning of bidirectional) to a (LEGO-Element-ID)
  24. I also feel that such kind of "customization" gets too complicated - not only to implement in the engine, but also too complicated for most of the users
  25. OK, I do understand the limitations of the framework and can live with the "missing" ordering (in my use of the API in most scenarios I will fetch all data by taversing through the "next" as long as it is not null). Are you using "Django REST Swagger" for generating the sager docu from your API? Meanwhile I added a lot of information to a copy of your original swagger-YAML trying to bring in also information and modelling of the paramters and especially schema of the result (which afterwards makes generating a C#-based client just a few clicks and importsinto a project). Due to time limits (this is really a hobby for me) I have it not for all functions (I started with those I know I (will) use). If you like, I can give you a copy of that file for a first review. Maybe it is easier to use a YAML-file for the documentation which you can update manually (and not by the automatic generation based on your API-implementation)... Best regards Dietmar