[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/biz/ - Business & Finance


View post   

File: 365 KB, 1200x900, 1405540416095.jpg [View same] [iqdb] [saucenao] [google]
425291 No.425291[DELETED]  [Reply] [Original]

Please explain how APIs work.

>> No.425296

>>>/g/oogle

>> No.425303
File: 153 KB, 500x558, 1401466820359.jpg [View same] [iqdb] [saucenao] [google]
425303

Watch
>How To Design A Good API and Why it Matters
on utube

>> No.425316

>>425303
This isn't really answering my question.

>> No.425319

No.

You're welcome!

>> No.425321

An API is the specific entry and exit points into a piece of software. For example, if I were to request location data from Google, I would use the API they have made for this purpose, which defines how they expect the request to be submitted, and what information I can receive.

>> No.425327

>>425291
$NEWL all in

>> No.425475

>>425291
>business & finance
>programming/coding question
Its like my university...

>> No.426670

this isnt really the right board but you posted a good ass.

lets say i write a program that plays tic tac toe. I want other people who are unfamiliar with the internals of my code to be able to extend my program, so i publish some methods, objects, and so forth to make it easy for people to do that. For example, I could list the following as an API


Player object
public void AssignXOrO(Symbol sym)
public BoardLocation PlayTurn()

Game
public BoardLocation[][] GetGameState()
public Player GetWhosTurn()
public bool IsWinner(Player p)

Someone could come along and decide i have a shitty UI, and using these methods exposed, they could write their own better UI. Or someone could write an AI Player that interacts with the Game by reading the gamestate and choosing a PlayTurn(), or someone else might try to make a network game by writing their own network server protocol and not worry about whats going on in the implementation that i did.

Makes sense?

>> No.426685

>>425291
basically that ass you're looking at there is the woman's API.
>woman
>not sure it is one.

>> No.426693

>>426685
and your penis is your API for her. she invokes your penis function when she needs that part of you

>> No.426698

>>425291
You don't have to know how APIs work in order to invest in NEWL.

>> No.426867

>>426698
are you talking about NewLead Holdings Limited?
it went from over 35k at the beginning of the year to 1.25 dollars today.
what is the reason for the down going? why do you think it will go up? are you hoping it will go up just becasue of this insane decline? analysis please. or link to analysis

>> No.427473

Web APIs?

They let a website provide a set of functions that arbitrary programming languages can access via HTTP requests. The response is usually provided as XML or JSON.

Generally an API runs alongside a website and provides similar information but in a format robots find easier to parse.

>> No.427535

>>425291
Your car API is your steering wheel and the gas and break pedals. There's a bunch of shit going on inside your car, but really only need to know about those things and what they do in order to drive, because the nice car engineers made it operable by the human meat machines.

It's what the programmers have given you to interact with their program, usually for other programmers and not end users. These are usually a set of functions and variables and how you manipulate those things.

So in Python, you have a math module that does math stuff. I don't know how they do math stuff, but I know how math works and I don't really care about the specific way they're making my computer calculate it. So to open up the math module I'll start with something like:
import math

now that I did that, I can refer to the number pi by typing "math.pi" which is a very intuitive way to refer to that number. To get the square root of 36 I type math.sqrt(36) which is only mildly less intuitive, but also lighter on the number of characters you have to type to use that function.

Maybe a less obvious API would be with Pythons graphics library, tkinter. To create a new window, I type:

root = tkinter.tk()

I can now refer to this particular window with the name I gave it, root.

Next, I want to put a circle in that window. But first I have to put the "canvas" widget in that window which will let me draw circles in it because that's how the programmers designed the API.

drawamajig = tkinter.canvas(root)
drawamajig.pack()

now, if I want to draw a line, I do it like this:

tkinter.create_line(drawamajig, 0, 2, 2, 6)

this could have been done with a completely different API if the designers so chose. I could have told the window I was planning on drawing some lines when I created the window like this:

root = tkinter.tk(drawable="yes")

Then maybe to draw line with those same coordinates, I could have done it like this:

root.line(0, 2, 2, 6)

But they didn't, so that won't work.

>> No.427702

>>425291

>Hurrdurr, I can be a sooper rich software haxor programmer
>Lemme google search how I do it
>API, what is that? That was never explained in the HTML class I took at community college
>Clearly programming is easy and I can learn everything I need to know about it in one thread on /biz/

Fuck off you lazy faggot

>> No.427728
File: 295 KB, 438x600, lizardman.png [View same] [iqdb] [saucenao] [google]
427728

>>425291
import urllib2
import json

>> No.428934

>>425291

OP that is a very lewd pic this is a work safe board please remove.

>> No.429184

>>425291
>Please explain how APIs work.
Each API is different, you read the docs to find out how each one works.

Why did you ask on /biz/ and not /g/?