Turnip-Calculator
Turnip-Calculator copied to clipboard
[REQUEST] Public API
Would a public API be possible? In our discord we keep track of everyone's prices and use this website for predictions. I wanted to make a bot to keep track of everyone's entries and it might be cool to be able to send the numbers through a public endpoint and receive the same data the chart receives.
Just a thought, not sure if anyone else would find this useful.
That would be awesome. I mean if it helps someone to make cool things, why not?
If I have the time I will see what I can do.
Please note that I will prioritize bugs over this request.
I'd be happy to take this one! I could spin up a relatively simple nodeJS API.
I guess my only questions to start with would be:
- Would this live in this same repo or be separate
- Would this API just calculate the same info that the frontend already calculates, or would it be able to do more (store data, etc.)?
Hey guys,
I've been working on a webapp for tracking turnip prices: https://kabu.wiarlawd.me
Maybe we could integrate it with turnip calculator?
Also API docs are avaiable at https://kabu.wiarlawd.me/api/docs
heh, I actually built one too... https://github.com/jamesaspence/actn-client https://github.com/jamesaspence/actn-backend
Can you explain a little about this repos? I just compiled the client, but I didn't have a chance to locally deploy the backend.
Although, I think this issue is requesting a pretty straight forward API. For some input, they want the same output that the chart receives. No authentication. No databases. No history.
Yep, sorry the repos don't have an updated readme - in all honesty the APIs don't have a ton of relevance to this work, short of being related to turnip price tracking and being an API :) it allows login and storing of historical price data which we don't have here. the actn-backend is the important repo in that it's the REST API (please keep in mind it was a WIP and abandoned once I found this and other sites!).
And yes, I figured as much - I figure a simple node API that uses the same JS that powers the front end calculations would do the trick nicely. As mentioned before, happy to tackle that if you're interested in it as well!
Would a public API be possible? In our discord we keep track of everyone's prices and use this website for predictions. I wanted to make a bot to keep track of everyone's entries and it might be cool to be able to send the numbers through a public endpoint and receive the same data the chart receives.
Just a thought, not sure if anyone else would find this useful.
I just finished a bot like this! If you keep everyone's prices in a database by island, you can pass the prices along to a string and append that to the share URL in a discord embed. My repo is private right now bc it's still kinda rough but I can share the command js file with you if you'd like
Would a public API be possible? In our discord we keep track of everyone's prices and use this website for predictions. I wanted to make a bot to keep track of everyone's entries and it might be cool to be able to send the numbers through a public endpoint and receive the same data the chart receives. Just a thought, not sure if anyone else would find this useful.
I just finished a bot like this! If you keep everyone's prices in a database by island, you can pass the prices along to a string and append that to the share URL in a discord embed. My repo is private right now bc it's still kinda rough but I can share the command js file with you if you'd like
My thought for using an api is to track who and when people are supposed to peak that way the bot can send notifications or members can use a command to get that same information. A share link would be simple to generate but the bot can't get much information from that.
EDIT: Also to other people's points, I do appreciate others sharing their repos but as the repo owner stated, I wanted something simple without an auth, history, etc. I posed this question on this repo since I really like the design of the frontend and I support the work in this project. I think I'd be nice to have one place support a public API instead of a lot people "reinventing the wheel" in their own projects (of course in some situations you would not want to use an external API).
Would a public API be possible? In our discord we keep track of everyone's prices and use this website for predictions. I wanted to make a bot to keep track of everyone's entries and it might be cool to be able to send the numbers through a public endpoint and receive the same data the chart receives. Just a thought, not sure if anyone else would find this useful.
I just finished a bot like this! If you keep everyone's prices in a database by island, you can pass the prices along to a string and append that to the share URL in a discord embed. My repo is private right now bc it's still kinda rough but I can share the command js file with you if you'd like
My thought for using an api is to track who and when people are supposed to peak that way the bot can send notifications or members can use a command to get that same information. A share link would be simple to generate but the bot can't get much information from that.
EDIT: Also to other people's points, I do appreciate others sharing their repos but as the repo owner stated, I wanted something simple without an auth, history, etc. I posed this question on this repo since I really like the design of the frontend and I support the work in this project. I think I'd be nice to have one place support a public API instead of a lot people "reinventing the wheel" in their own projects (of course in some situations you would not want to use an external API).
Right. I thought you wanted a solution for both tracking and predicting the prices. I have a simple web API set up (https://kabu.wiarlawd.me/api/predictions?input=) that generates prediction data. Right now it only generates random data as a stub. If @elxris permits I could port the prediction logic within utils/patterns.js
into my web API.
Ideally I want to contribute to this repo by extracting an interface of this computation, so it can be used a js library, but I don't know where to put the code since this repo's structure is for a single react app.
Well we could always create another directory, api
, or even just server
, and have it live side by side with the react app. I'm not sure what the owner uses for hosting but it's pretty trivial to spin up a koa / express app that will proxy requests to the react app through to the front end while also handling requests to a subpath (i.e. /api)
@Jarvie8176 You're free to port every part you want!
@jamesaspence Right now I'm not hosting anything. All files are served through Github and Cloudflare CDN's. I have one Firebase Function to generate the previews under the share modal. (I want to enable Open Graph previews, but that will come later). I'm seeing that it could be possible to host a static API through Cloudflare Workers. (Static in a sense of no databases involved)
If anyone finds this helpful this is an API I just mounted.
GET https://api.ac-turnip.com/data/?f=100-90-90
This would be a request to the API for 100 base price and Mon 90 AM, 90 PM values. If you don't have a value, like the base price it would be
GET https://api.ac-turnip.com/data/?f=-90-90
If you have more data just keep appending it with a -
Example response.
{
"filter": [
100,
90,
90
],
"minMaxPattern": [
[38, 142],
[85, 142],
[58, 202],
[48, 602],
[38, 602],
[38, 602],
[33, 602],
[29, 602],
[24, 602],
[19, 602],
[14, 202],
[9, 201]
],
"avgPattern": [
102.61,
107.51,
100.05,
98.59,
99.72,
104.46,
106.26,
105.92,
101.46,
93.45,
83.76,
86.73
],
"minWeekValue": 85,
"preview": "https://ac-turnip.com/p-100-90-90.png"
}
Nice! I'll check this out more when I have the time. Probably this weekend.
I'm trying to have a lot of AC:NH websites API Documentation in one place : https://animal-crossing-api.glitch.me/ac-turnip.com So I did this one's and added it to the website. @elxris's example helped a lot.
@elxris is the source code for the API available anywhere out of curiosity?
@jamesaspence No, it’s a serverless function on a CloudFlare Worker. I created it on the fly with the web editor. I may work on creating a branch or a directory on the sources to disclose how I build it. The same as the preview generator.
@elxris Thank you so much for releasing your api. 😃 I've made a command on my Discord Bot with it, and works wonders. 👌
Thanks for this endpoint! I made a little thing with it: https://zenahirsch.com/stalk-market/
The data I'm receiving from the API doesn't quite seem to match the actual dashboard data, not sure why.
https://api.ac-turnip.com/data/?f=98-91-114-137-143-140 https://ac-turnip.com/share?f=98-91-114-137-143-140
Still really cool though!
Yeah! Sorry about that. I will see if I can update the API. API is v1. Web is v2.
@elxris 这个API非常棒,但是我在中国,经常超时,我是否可以自己搭建一个API?或者别的解决方式?
This API is very good, but I often run out of time in China. Can I build an API by myself? Or some other solution?
I am using CloudFlare Workers to set up the API, but I think you can build an api for your needs as the code is publicly available.
I suggest you to use node.js. Since 2.0 it’s in Rust. But the WASM is available and you could use it with node.
Update: API and Web App predictions should match because now both use Rust-WASM powered calculator. 👍