How can i get json data from a URL and post the new itens in database every 30 seconds?

I want to create a database on my website to show the data in a table. I have the api link that returns the data in json format. How do I insert new data into my database?

I’ve tried using velo’s tutorials but I’m new to this platform and this programming language.

the url response is:

[{“id”:“Wplzzvmgln”,“created_at”:“2022-04-08T06:22:31.641Z”,“color”:2,“roll”:9,“server_seed”:“6650b67d13ac49840b29100205c43ea049e563d88aaef8cdcfaa7abd5cffddbd”},{“id”:“LKl3mAWO1N”,“created_at”:“2022-04-08T06:22:01.609Z”,“color”:2,“roll”:14,“server_seed”:“3b3c042b64e92bea5b1cd5232e51870cb6f605cf72a62b9453a54da71d2eea6f”},{“id”:“jxrMJD721Q”,“created_at”:“2022-04-08T06:21:31.575Z”,“color”:2,“roll”:13,“server_seed”:“e1b7c1b7f07a9893c1a3ad22962a2ee14ef113733acb4aeceb33dcaee0f206bf”},{“id”:“9YrJJjNMrK”,“created_at”:“2022-04-08T06:21:01.543Z”,“color”:2,“roll”:10,“server_seed”:“c0364a5762344acd5b4117098805fe591d971999bde641ee0f44117cb3d29f25”},{“id”:“mDlZJDwelj”,“created_at”:“2022-04-08T06:20:31.496Z”,“color”:2,“roll”:13,“server_seed”:“138ec838229bbbe9f746daacc5133f245cec91b078de7d4c4a0a9fb6ae651721”},{“id”:“96rXJQ63kO”,“created_at”:“2022-04-08T06:20:01.456Z”,“color”:2,“roll”:13,“server_seed”:“3b6ad4de851624619adbee62d420d1c362d318ac1c17e64b57fbed1077835557”},{“id”:“KV16BpxZ1B”,“created_at”:“2022-04-08T06:19:31.420Z”,“color”:1,“roll”:5,“server_seed”:“014a2be5861ae4d23e4c8ebd3ad4f8f3afe8a60a1b56fa947c1baf6ff7f42e65”},{“id”:“pJ1oq7vqld”,“created_at”:“2022-04-08T06:19:01.388Z”,“color”:1,“roll”:3,“server_seed”:“498ead685fa5ece25a29b24a32e8eb21da6f7b5e98161a74da0ea9ea76a0bd81”},{“id”:“YArwnvw2lz”,“created_at”:“2022-04-08T06:18:31.355Z”,“color”:2,“roll”:13,“server_seed”:“8ee6c0157754768eabf7ecf56e7dcdc49b54900d99ca1a31fe105ad3f588d491”},{“id”:“4ekjPpRQr9”,“created_at”:“2022-04-08T06:18:01.320Z”,“color”:2,“roll”:13,“server_seed”:“4992ff8eb4b263a2cdd047f0cc580b3b32dab537ad38840b61fabba87f3dcc52”},{“id”:“2O1BJnXV1K”,“created_at”:“2022-04-08T06:17:31.276Z”,“color”:2,“roll”:12,“server_seed”:“2c4785a18c293f8562b2f95289782a594bc5dc3c940cb186ee7949aa9b4a81da”},{“id”:“o5rVJVGqrK”,“created_at”:“2022-04-08T06:17:01.240Z”,“color”:1,“roll”:2,“server_seed”:“58f46f3c62419b29029d93101e1943aa3898be19d99b1249c765b4f346493510”},{“id”:“Jw1DJgPLlE”,“created_at”:“2022-04-08T06:16:31.205Z”,“color”:1,“roll”:4,“server_seed”:“0a1e91eccf96a53cdb716ef3a97cb6cc345d0dfe4e7cda5ec88a47a86ecd77b7”},{“id”:“4J1m0OXyrj”,“created_at”:“2022-04-08T06:16:01.171Z”,“color”:2,“roll”:11,“server_seed”:“20231ed7092cfe983b33b08b514a39bf694d27444fbdd4016264e58cc8bfde4e”},{“id”:“zokg9AZary”,“created_at”:“2022-04-08T06:15:31.138Z”,“color”:2,“roll”:9,“server_seed”:“7d28d851a4f1838f5bb3723762ef356fa05d42b509fbb00adabaa64c15d55491”},{“id”:“04lQJqmNrn”,“created_at”:“2022-04-08T06:15:01.100Z”,“color”:1,“roll”:3,“server_seed”:“4e5e84d5c951c9e6ebc31919ef317d6a625e5091040e482dd3a69d4239381978”},{“id”:“eRlv4v8b1j”,“created_at”:“2022-04-08T06:14:30.887Z”,“color”:2,“roll”:12,“server_seed”:“e38c28899664cb31d593ad0f9e8da72805b0591d53f3a5b6a8a81a36219d1cae”},{“id”:“8Lkn8Ka7r3”,“created_at”:“2022-04-08T06:14:00.850Z”,“color”:1,“roll”:2,“server_seed”:“37342afa658bbf62387c398f91c3a523aab6a2ccb39f52118edda64531d42bc5”},{“id”:“O2l4Dy6Vln”,“created_at”:“2022-04-08T06:13:30.814Z”,“color”:1,“roll”:3,“server_seed”:“7e5be1c4e9223f35754a1c53ce10d058c236c1f2a41953a98aa14941e7c5880f”},{“id”:“AKl5VbRBr9”,“created_at”:“2022-04-08T06:13:00.780Z”,“color”:2,“roll”:10,“server_seed”:“6925a50931931f70985ba0b3e199e3cc37b3f1fe8907e6d398c57a6d81fa529c”}]

The algorithm would be:

if id is not in the database

  • insert new data into the database

else
wait 20 seconds and run the process again

I Want to show data like this:

and in table format with a option to export data to .csv

Can someone help me please?

i’ve already tried :

  • read wix fetch
    -read wix getjson

but i dont undestand as well.

Create these fields in your database collection (including the id field which represents the external id, and the created_at - external creation ti,e etc…).
then use return wixData.bulkInsert(‘collectionName’, items) to insert it (the items is what you got from the external source when you run wix fetch after parsing it with .json().then(). )

Thanks for the awnser! But can you help me with the code? i dont know how to pickup with wix fecth

https://www.wix.com/velo/reference/wix-fetch/fetch

https://www.wix.com/velo/reference/wix-fetch/getjson