Jump to content

API

EPPHO

Hello! Quick question, does someone know if there are any APIs that convert from metric to imperial? I have something to do in JS for a website and I HAVE to do it with API calls.

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, frozeNNN said:

Hello! Quick question, does someone know if there are any APIs that convert from metric to imperial? I have something to do in JS for a website and I HAVE to do it with API calls.

Does is specifically say "http API" or just "API" because of its the later creating any sort module or class would class as an API.

 

Could even use an existing one such as

https://github.com/ben-ng/convert-units/blob/master/README.md

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

https://www.neutrinoapi.com/api/api-examples/node.js/

Just fyi it was the very first google result of "metric to imperial coversion API" ;)

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, frozeNNN said:

I checked that before posting, am I blind or there's no conversion for metric-imperial units on there?

I would assume so. It says "Convert most known measurement types: imperial, metric, mass, length, temperature, time (and more)."

 

Might have to just dig through the api documentation more (which is really good practice and probably why this is a requirement, if this is an assignment)

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
Share on other sites

Link to post
Share on other sites

Imperial is now purely based on the metric system. That means there exists constants that will be valid "forever". Depending on your use, implementing the conversion yourself might be faster than trying to use some API. Especially when it's really straightforward like now.

Link to comment
Share on other sites

Link to post
Share on other sites

Im with @DevBlox on this one. Metric to imperial unit conversions are trivial. 

 

E.g. Kg 《 Lbs × 2.205

Mi 《 Km  x 1.609

 

They're extremely simple math functions that realistically would take probably about 30s to define a function declaration and definition that conforms to whatever programming styles or standards you're using in any langauge.

 

Cant use code blocks because of mobile but here some c style code that you should get the bigger picture and be able to implement in any langauge.

 

float ReturnUnit UnitToUnit(float InputUnit)

{

return InputUnit * Conversion;

}

 

You could build your own API in under 10 minutes for just about every relevant conversion between systems.

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, DevBlox said:

Depending on your use, implementing the conversion yourself might be faster than trying to use some API. Especially when it's really straightforward like now.

Since it's such a specific requirement (conversion and it HAS to be done through consuming an api), i'm guessing its some kind of homework assignment. I just want to throw this out there, since i also think doing a Rest API call for something this trivial would not be a good actual solution.

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 5/17/2019 at 6:38 AM, reniat said:

Since it's such a specific requirement (conversion and it HAS to be done through consuming an api), i'm guessing its some kind of homework assignment. I just want to throw this out there, since i also think doing a Rest API call for something this trivial would not be a good actual solution.

 

On 5/17/2019 at 5:36 AM, trag1c said:

Im with @DevBlox on this one. Metric to imperial unit conversions are trivial. 

 

E.g. Kg 《 Lbs × 2.205

Mi 《 Km  x 1.609

 

They're extremely simple math functions that realistically would take probably about 30s to define a function declaration and definition that conforms to whatever programming styles or standards you're using in any langauge.

 

Cant use code blocks because of mobile but here some c style code that you should get the bigger picture and be able to implement in any langauge.

 

float ReturnUnit UnitToUnit(float InputUnit)

{

return InputUnit * Conversion;

}

 

You could build your own API in under 10 minutes for just about every relevant conversion between systems.

 

On 5/17/2019 at 3:17 AM, DevBlox said:

Imperial is now purely based on the metric system. That means there exists constants that will be valid "forever". Depending on your use, implementing the conversion yourself might be faster than trying to use some API. Especially when it's really straightforward like now.

I know it's easy to write these functions but I have to do it through API and I don't know how to create my own API or whatever.

Anyways, I implemented something else and I think that'll be enough. Thanks for help! :)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×