Closed DustinHaefele closed 4 years ago
This is for issue #162
Hi @DustinHaefele ,
Thanks for the PR! Is there a place where we can access the list of valid models/make?
Hey @corradio. Sorry, I have been hiking in the Andes so I just got back online to see your question. I'm not 100% sure what you are asking so If I don't quite get to an answer let me know. There are a couple resources.
Here is a link to the documentation for the API: https://www.fueleconomy.gov/feg/ws/#fuelType1
At that link you cant find this link: https://www.fueleconomy.gov/feg/epadata/vehicles.csv.zip which is a download for a CSV file for all the data on all the makes and models from 1984 to present. So that is a big resource.
The other thing that is possible is there is an endpoint to get all the makes by year, then you can use that list of valid makes to get a list of valid models for that make and then choose a model and get the emissions data for it. You can also break it down further to get options so if a model comes in different engine styles you can choose which one you own and get the emissions data for the exact option of vehicle you are driving. I can keep working on this and build it in a way that is more usable for the app just let me know at least an idea of how it would be the easiest to use for you.
Hi @DustinHaefele , Thanks for the reply, we'll get back to you soon! Olivier
@martincollignon what do we do here?
@ayakoaohara is working on something similar, which I think we'll pick as it's more extensive. However I need to check if we can borrow some things from this (especially with cars from the past)
ping @martincollignon
@ayakoaohara - could you do a draft PR so we know where we are and potentially others can help?
Closing due to inactivity. The PR can still be re-opened as draft.
I wrote three functions that make use of the US government API. One function is to get all the models given the make and a year for a vehicle. I wrote this to make sure that the correct model name can be put into the second function. (This is the second function)
The first function is the main function that returns the kg of co2 for a trip, but it needs a vehicle id, so I integrated it with the third function which takes a make model and year and returns an id.
I put this all in the transportation.js file, which I don't really think is the right place for it but I wasn't exactly sure how to organize it. If you give me some direction on how you would like it integrated into the code base I can modify it that way.
Also this relies on a node package that translates the xml response from the api into an object.