Forum Academy Marketplace Showcase Pricing Features

Trying to get data from a json url

How would I go about getting the information from this into my bubble database?

http://data.ny.gov/resource/d6yy-54nr.json

Hi @marcusjamesreed, I got this set up for you in the forum app so you can replicate in your own app:

Take a look at the API connector plugin in the forum app and see the “NY Gov” API at the bottom of the list. Then look at the NY Gov page in editor and preview. I added a repeating group to the page and set the API as the type & source. Text in cell pulls in the data dynamically. Let me know if you have any questions.

Editor: https://bubble.io/page?type=page&name=ny_gov&id=forumapp3&tab=tabs-1
Preview: https://forumapp3.bubbleapps.io/version-test/ny_gov?debug_mode=true


Gaby | Coaching Bubble

1 Like

Thank you so much! You’re amazing. I will examine it further and see how I can use this data.

1 Like

Okay, I was missing the API creation in the plugins settings. However, now that we have this data am I able to extract each winning number result independently so that I can have each winning ball. I managed to do it in that same editor for the powerball number by using the truncated from end. But I’m stumped…

Also the date is in a strange format. When I tried to format it for Date it doesn’t bring it up.

Okay I think I just figured out a way to do it, by using a combination of truncate and truncate from end.

Format types can be modified when you initialize or modify the call in the API connector. See screenshot. I made the change for you, so you should be able to format properly now. Bubble had assigned it as text by default.

Yeah, the numbers aren’t returned as a list - just a single text string, so you’ll have to truncate from both ends for each number. You’re doing it right!

Thank you! I think this program is wonderful but I just hope that I don’t incur too many workflow runs…

Sorry for being so needy, but what I’m trying to do with that data seems to be quite difficult.

So far I have three datatypes…users, drawings, and tickets.

Drawings have tickets which have users…

I manually create the drawing record which is indexed by date, and has winningNumbers field which takes numbers as a list, a winningPowerball field, and also an isActive field which is boolean set to true by default.

The tickets have a drawing field, a pickedNumbers field which also takes numbers as a list and a Powerball field.

What I want to happen, is everytime a drawing is done, and the data from the json url is updated, the drawing is updated to reflect that the drawing isActive field is then false and the winning numbers be updated for that drawing as well. I then want to find the tickets associated with each complete drawing and determine if they have won.

Is there anything like a CRON to do something like this?

I am reading now about how I might have to use Zapier to do something like this.

I just noticed a very odd thing. The dates being returned from the API call do not match. For instance, the last entry in http://data.ny.gov/resource/d6yy-54nr.json is for 2/25/17 but when displaying in Bubble it shows 2/24? Why is this happening?

If I display the results in a repeating group:

The json shows:

but I get back this data:

Do you see how the dates are different?

The datetime “2017-02-25T00:00:00” means midnight in the UTC timezone, which is likely different from your local timezone.

Also, to extract the individual numbers from the text string “01 02 03 04 05 06”, you can now use the :extract with Regex pattern \w+. This will give a list of six texts with the number in each.

2 Likes

I am unfamiliar with regex. Is this pattern giving me all the numbers? How do I extract each individual number?

\w means a word character, could as easily have used \d for digit.
+ means match 1 or more

So there are a lot of alternative patterns to use to match two digits separated by spaces, probably simplest is:
\d\d

http://www.regexpal.com/

You can play with Bubble’s version at: https://forumapp3.bubbleapps.io/version-test/regex2

The result will give you a list of 2-digit strings.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.