logo

NJP

#3 Get Coin History Scripting Part 1- Integration

Import · Jul 06, 2020 · video

hi everyone so we are going to create our second dress request you know if your designer and this time we are going to get the coin history so for the past five years for any request and then paste our script there and test if you have okay so the first thing that I want to show you is the end point that we are going to use so this is this is the end point that I'm going to use you can see here we have to put the coin ID any happier the timeframe okay we are going to use this end point in order to get the result in pro designer so this is this is the response that we get we get the price on the time stamp so if you put in a tool like Jason Carson online that you can easily find you can actually see the result in on the right side and you have some numbers for example you can see the number of elements in the eastery area so we have thousand eight hundred twenty five elements so it's three zero it's our first element for example you will have the price here timestamp and this is for example one two three four like this okay this is a big response and one action output cannot contain thousand eight hundred twenty-five elements it is so big so that we can do for that what we can do is basically we can split the response into multiple occasions going to divide this response into multiple chunk and each one will correspond to an array and also it is going to be also our action output so we will have eight action outputs in total in order to parse this entire response that we have here script and I'm going to show you we are going to write our script here and I'm going to explain you how we are going to do that so on the left side here I'm gonna have some sort of fuse which is actually going to represent what I'm going to actually write on the right side here in the notes where I'm going to put my code so let's we will understand what is it exactly and then for example price time in price time price and this is the Indus okay this is like the array that I have for Bitcoin for the resulted fee that we get here okay so so this is the last days which is because we have thousands and each individual an H is going to be 120 okay and then we continue on to 244 that's the that's basically 245 that's basically the length of the array so how do i define this number how do i why not wonder why not 300 so our script in other parts repetitively and then find out like in my for loop people see you riding some 12 and I wasn't well okay now to find what is the exact length that I can have for one action output so I tested my for loop until 200 I got all the response I take a test of an 246 I got some error so that's how I came to like to do these numbers okay so if you want you can actually do that and then find these numbers but you are going to end up here so now let's put [Music] JavaScript code right so the first thing is question for creating arrays so I'm gonna show you how uncool here that's the one here not this one this one let me just make it so okay it's quite simple all you need to do is to repeat and then you put corner ABC and then so on then I just copy the school and then put it in my cool okay I have to give you a brief explanation this is like the first part of the code we have an if condition which is checking if you have a successful response or not okay so status under school code is the valuable that we have pass step and this will continue the state is cooled that it is getting from the response party okay that should be 200 and if a is 200 we have a successful response then we we are going to parse our response body okay and we create [Music] [Music] we can access and to do is to point and have to bracket the first one you will have zero and the second one you will have one because number one okay so we can organize the one you can put all your arrays in a certain table this is but the best thing here is to do like this okay this is how I'm going to use you know code is going to be much more efficient and easy to access these these are from coronaries okay let's copy now this one and then put it in our cool right so this is our first product record which is quite simple but now we have to define the name for these arrays right we haven't done that you should be okay for this for the first time okay the one that I have here for the second time two times the same number I have a different plan for I'm going to do so this is the fire that I want to create one for inside a metaphor which we run until I'm to the certain learn that will define from the beginning okay so those here okay so every which will have been meant up to each individual areas that I have here so 245 for the 505 on an employee and 240 540 540 and 120 these are the lengths okay this is the last in this for example for the second for each [Music] okay great so if you have a fastball to clear now that's right I can put smaller than 8 oh I can't put this value because no obviously that corner is is the length of the coin arrays it is paid okay we have a to them in here so I'm going to put here smaller than going erase lent okay this is better than putting a specific value why because let's say for some reason who like to have in your corner here and then one two three four five six seven right this is equal to have a as a variable here I mean the small letter Z which is equal to 245 245 okay so I'm going to have you 145 so the look is going to be on 245 okay I mean 244 but you get it so I plus plus thing I'm going to just but this okay I have my second for a loop now so what do you have done so far is we have to define these some noobs okay we haven't actually talked to the system like the first you have here for example when a equal to zero and it's going to run for two hundred and forty five times it should correspond to a certain array that we have in the Canaries right we haven't told that we have we haven't created any relationship between corner is that you have you inside okay so that's what we are going to do next okay we are not only the relationship into these boxes boxes okay so the next thing is we are going to add objects okay my objects time and price okay just do the same thing I'm gonna just take the cool so what is the first thing [Music] coin I'll be Jade like this and then price equal to to a certain syntax that I'm going to have which is actually going to get the value but I bet no one here around the price how I can get the price yes I have response body which contain the past response body okay so I'm going to use that value so I'm gonna have you right here so let's go to our online and see how we can get it so if you have access to the value price history and eastery is an area so you should have the value 0 into the brackets and then price you can get this value and if you do the same data dot history zero game forestry and then that times time we can get this specific value and if you write this one or this one or this one issue I'll change the value that we're gonna have into the brackets for the mystery area okay so let's go back here and then write that so I'm gonna have a string dot price okay so instead of having nothing here I'm gonna have something [Music] I'd want everything that I have in mind in the response here okay so I'm going to okay for now haven't change it I mean we will have something more inside not just pie and you must do that once I finished the script for the second part which is during the time stamp so I'm going to change price to time stamp we have one two three four five and then 244 okay the last one for the first loop for the second loop we are going to add for the valuable I have the same thing but that's not what if you go back here this message this is 0 this is 1 this is 2 this is 3 true but once you have done a hop for all of this you got the data for all updates for the next thing you're not going to start again for the second loop but I could do that means you're just taking the same value again that's not one where you have to start is 245 right so I'm going to look for me at the value that I should start from for the second loop in history arrow that the value that I should have in my theory okay so let's go here the sky complex I want 45 right so what I'll be here I add to 244 I have just one and I'm going to get harder than 45 and then again I'm going to add [Music] 45 so I'm going to 89 so if you follow the same logic you'll all the rows that I should get 7 1 2 2 0 let me just I don't know everything out here I'm just just putting the reading from you don't want you 6 5 mm okay so I'm making some mistakes the most so I'm gonna have 1975 here and I'm going to have 1 2 0 1 3 6 5 and then 1 6 5 1 6 0 5 and a 2 fold it take okay so so that I should use my history early each time I'm changing from a I should have in my estuary like you instead of having I equal to 0 I should have 245 so how we can have that value here okay if I keep it to to this plug into this bracket I cannot have those values that I have here so for that what I'm going to have first do first is I'm going to create this so I have it here nice copy and into this bracket and this bracket okay this is how you can access value that you're having your BA and the first value that we have which means like 0 it is 0 ok so the logic that we have you I plus 0 so for the first loop the second part of the code I mean not to go 2nd part of thing that we have in our estuary is going to be always 0 because we have value okay that's a value ok so [Music] 1 plus u 2000 to pursue like this ok for the first two it's like it's like it doesn't make sense but for the second look what's going to happen when we are here five to even be zero so I'm gonna have 0 plus 245 then here I'm gonna have 0 1 plus 240 v which is 246 okay so in this way I can have I can go into 489 for the second group that I'm going to have okay so this is how we can actually get that specific element into our estuary and then get the entire okay sorry the entire array the entire data that we have in our history okay so let me just now add this one to the second part of the code here right here okay okay we haven't stored it into our cell so I'm gonna just delete this part delete this one as well so we're going through we are doing a loop each time when I'm at this position I'm telling - this is - hey create an object going to the value from this very and you have it okay but we are not telling at the same time is true the value here so we're busily presenting sir this is the first element of my point array a right and then the second element and so on okay [Music] [Music] send the object into that first cell that we have in your coronary P so that's what we are going to write here okay so first thing hold the axes going our age so it's quite simple as logic so I'm gonna have to use coins that we have here so here also the sir so I'm gonna put another one and okay the first part of the first to bracket is accessing in Koine a and then the next one is accessing easily yourself that we have and 0 correspond to this specific part the specific cell so now this is okay that I need to have for all cells not just for one the first one so I need to know how I can change not to go to for ourselves so each time is going to add in that specific South today so the first one is in my corner I really have to choose the corner and how do I change you from the corner ace okay if I go back up here have 0 1 2 3 4 5 6 7 ok the one you value which is changing is the first part of the code okay so I'm gonna have to write here instead of having 0 sorry instead of having 0 yes I'm gonna have to have here it's going to be 8 okay so when bar 8 equal to 0 I'm going on the first trip this one is going to require is a zero so I'm gonna have to choose this corner a 8 then this one I'm not touching it because it's always the same thing so that's what we saw before it is always zero here okay the next one is the last one which is I cannot have 0 as well here so I should have another value which is going to be I because I is gonna know from 0 to certain right so this is how we can go through we can select first the array then go to each individual cells okay for our first okay so then I'm going to again imagine that we have these tools and then once you are at this point you have the object right but you haven't stored somewhere that's why we have this code which is actually pointing this specific cell with this syntax okay we have they're gonna replace a what we have in that time is going to be zoom and is going to be zero okay is actually going to have we're gonna point to that cell okay we haven't finished with the code we have to put eco and then put our object okay so this is how at that specific moment we are putting the value into that cell okay so notice how we are done with the code for example okay this is for Bitcoin or any other coin where the length of the response body of the stra is thousand eight hundred and twenty five but not all coins have the same length okay so have a table here Bitcoin - to create they have different lengths so we are going to see next how we can actually give the data store the data for all coins not just for one coin but for all points so see you in the next video

View original source

https://www.youtube.com/watch?v=swuD5ghV73I