Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
How to use API in c#?
if we have API Key and serverURL(test url or sandboxURL) then how we use it.

sanbox url=http://beta.ipviking.com/api/[^]

apikey=** REMOVED **
Posted
Updated 9-Jul-13 1:29am
v5
Comments
Thomas Daniels 9-Jul-13 6:45am    
Which API?
[no name] 9-Jul-13 6:48am    
ipviking api
[no name] 9-Jul-13 6:50am    
API KEY:** REMOVED **
sandboxurk=http://beta.ipviking.com/api/
METHOD=ipq


its return json or xml result...
Dave Kreskowiak 9-Jul-13 7:29am    
Thanks for posting YOUR key and giving it to the world to use! I'm sure every a**hole who wants to abuse that site using YOUR key will appreciate it!

1 solution

Hello Brijesh,

The IPVIKING API documentation states following

  • IPViking API uses REST (Representational State Transfer) design principles with the following format extension JSON and XML.
  • The API is entirely HTTP-based and support methods GET, POST, PUT and DELETE
  • API is based on HTTP Status Codes and will be returned for every request.

Being an HTTP API you can use WebClient class. Shown below a sample code for invoking risk API.
C#
HttpWebRequest request = HttpWebRequest.Create("http://api.ipviking.com/api/");
request.Method = "POST";
string postData = "apiKey=** REMOVED **&method=risk&ip=10.10.1.1&";
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusCode);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string strResp = reader.ReadToEnd();
Console.WriteLine (strResp);
reader.Close ();
dataStream.Close ();
response.Close ();

Regards,
 
Share this answer
 
v3
Comments
[no name] 9-Jul-13 8:14am    
but its not working....
Prasad Khandekar 9-Jul-13 8:52am    
What do you mean by not working? What all errors are you getting?
Prasad Khandekar 9-Jul-13 8:57am    
Hello Dave,

The key I included in my response is not a working key at all. It's just a random hex sequence. I am not sure though whether it's the same with the original post.

Regards,
[no name] 9-Jul-13 9:02am    
error 400(bad request)
Prasad Khandekar 9-Jul-13 9:37am    
Try calling ipq API. Change the method=risk to method=ipq. Also set Accept type to application/json (request.Accept = "application/json").

Regards,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900