fetching user media from instagram api without user id - api

I did what #krisrak told me to do. I used two API calls.
One to search for the username with
https://api.instagram.com/v1/users/search?count=1&q=USERNAME
and i got the user id from there to perform the second API call
The second call was
https://api.instagram.com/v1/users/USER-ID/media/recent/
This worked perfectly until I searched a certain username and I was given another. So I want to know if there's a sort of where clause to use to get the username I want from a list of results gotten. So my 1st call would now be
https://api.instagram.com/v1/users/search?count=0&q=USERNAME
to enable me get all results.

If there is no match, then that username probably does not exists, go to instagram.com/USERNAME and check if it exists. You may have to ignore and display that username does not exist.
BTW to get all the results, just remove count=1, then it will return a bunch of usernames that match similar search, usually the first one will be the exact match, so thats the reason count=1 is used to match a particular username.
https://api.instagram.com/v1/users/search?q=USERNAME

Related

GoDaddy Deleting a single DNS record through the API using Bash/Shell script

I'd like to delete a single DNS record (an A record) through the API via CURL or any other Shell/Bash command.
I also tried to access GoDaddy's website but unfortunately it no longer exists and returns 404.
https://www.godaddy.com/community/Managing-Domains/Deleting-a-single-DNS-record-through-the-API/td-p/108003
Is it possible, how can I do that?
EDIT The original answer seems to be obsolete
GoDaddy has added the respective endpoint to delete a single entry. So now you can do
DELETE /v1/domains/{domain}/records/A/{name}
Original answer
Unfortunately, godaddy's api does not provide the endpoint for deleting a single domain record in a single call. So you will have to
GET /v1/domains/{domain}/records/A to fetch all A-records for the domain first (https://developer.godaddy.com/doc/endpoint/domains#/v1/recordGet)
remove the record to delete from the resulting list
PUT /v1/domains/{domain}/records/A the modified recordset to replace all A-records for the domain with the given list of records (https://developer.godaddy.com/doc/endpoint/domains#/)
As the API endpoints return/expect JSON data, you might need some additional tool to manipulate the json data. You might find something in this answer Parsing JSON with Unix tools
You might be tempted to use PUT /v1/domains/{domain}/records/A/{recordname} to replace all A-records with the given name with the provided list of records (https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceTypeName) using an empty list of records in the body. The last time I tried that, it didn't work.

How to create relationships in a RESTful API

I have 2 tables, User table and User_token table, they are one to one/none relatonship, not sure how to create this RESTful API.
i prefer to setup
# to get user attributes
GET /users/123
# to get user's token
GET /users/123/token
or should i create
# to get user attributes and token by JOIN the table
GET /users/123
the argument we have here, if we are doing the first setup, which i like it, it takes thousands of API requests compare to second one
that is depend you requirement.
for example if you need User Attributes and Token every time than
# to get user attributes and token by JOIN the table
GET /users/123
is better.
other wise another approach is good to get required data when needed.
REST has nothing to do with your database structure.
Your resources can contain properties or sub-resources. Every resource has at least one resource identifier (URL).
So in your case the GET /users/123 is a valid solution.

LinkedIn connection search by first name and last name

Is there way to search first name and last name for linkedin connection filter using LinkedIn API?
Suppose I am authenticated by linkedIn and show connection in popup.LinkedIn connection response only 500 connection one time request. So I do paging 500 connection. But I want to send invitations to two persons, so I want to give search widget by first name and last name from my LinkedIn connections.
You could use the People Search API to search on first and last name, restricting the search to just your connections:
http://api.linkedin.com/v1/people-search?first-name=Clair&last-name=Smith&facet=network,F
Update:
In terms of 'filtering' the returned values to remove the current user making the call from the result set, you should check for the returned user's relationship to the viewer:
http://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name,relation-to-viewer:(distance)))?first-name=Clair&last-name=Smith&facet=network,F
Then check the results, and remove the users that have a relation-to-user of 0.

Is there a way to return the search term with the Foursquare user search API?

I'm doing bulk user lookups via email address (e.g. users/search? email=joe#foo.com, fred#bar.com, etc), but I noticed that it's not returning the email addresses with the search results. Is there anyway to do this?
Alternatively, I could do a single email address search per request, or do a user lookup by id on all the results I get back, but these options seem wasteful and inefficient.
User email is not one of the fields that the API returns for /users, see:
https://developer.foursquare.com/docs/responses/user.html
Usually API's don't return emails in the clear.

Organising resource (URI) in REST API

Scenario 1
In my web application say for there is a screen for adding an employee to system. As soon as user tabs after entering name of the employee, it generates the employee code automatically (which is the next field) based on some logic and already present records in the database.
Now I want to expose rest API for this application so that third party devs can build on top of it. So, I will have a resource called as /Employee which will respond for GET, PUT and DELETE verbs. But when a client needs to autofill the code, which is a GET operation, it will be on what resource? Should I make a new resource /EmployeeCodeFor/{Name} or I should get it on /Employee/{Name}/GenerateCode? If I go with /Employee/{Name}/GenerateCode then what about my resource to GET, PUT and DELETE for Employee i.e. actually /Employee/{Id}?
Scenario 2
Here lets take the case of a stackoverflow post. So lets say the resource would be /Post/{Id}. In the same way as in the previous example it lists me possible duplicate question as soon as I tab out of the Title field.
Again on what URL I should get those possible duplicates?
I can't think of more scenarios just now. But many such kind of scenarios may come up in real life application development. How to implement them in RESTful way?
Update on scenario 1
Code and Id are two different fields. Id is primary key, code can be duplicate across departments just to illustrate. Also to generate a code, name should be provided first. So, if user types a name "FirstName LastName" then server might generate FL003 as code assuming that there are already two more employees with firstname starting from F and lastname starting from L in the said department. Department can be identified based on the logged in user.
One way to allow the server an opportunity to pre-fill a bunch of elements in a new resource is to do
POST /Employees
{with empty body}
=>
201 Created
Location: http://example.org/employee/3443
<Employee Id="3443">
<Code>E1001</Code>
<FirstName></FirstName>
<LastName></LastName>
</Employee>
This gives the server one chance to provide default values. If you are looking for a more interactive way for the server to provide feedback during the input, I have another approach but it will take quite a bit more explaining.
Scenario 1
Let say your employee code is a unique identifier. In this case, to get it, you would allow the user to complete any field for the new employee and then make a POST. The server would generate the code and respond to the POST with a link to /Employee/{generated_code} which is the record for your newly created employee.
A GET on /Employee would return a list of all employees. A GET on /Employee/{a_code} will give you the employee detail.
Scenario 2
You could have some kind of query on the /Post collection like /Post?title_like={question_title}. A GET /Post?title_like=REST How to would return you a list of all questions containing "REST How to".