Get File (v2)

The getfile API allows users to get the validation results file for the file been submitted using sendfile API. Please refer to the C# example for details.

GET /v2/getfile

API URL: https://bulkapi.zerobounce.net/v2/getfile

URL Parameters

  • Parameter
    Description
  • api_key
    Your API Key, found in your account.
  • file_id
    The returned file ID when calling sendfile API.

If you want to call the API from your browser to test it, all you have to do is to replace the API KEY with your key and the FILE ID with the returned file ID from sendfileAPI:

https://bulkapi.zerobounce.net/v2/getfile?api_key=replacewithyours&file_id=[replacewithyours]

GetFile Code Samples

  • Visual Basic
  • C#
  • PHP
  • Java
  • Python
  • Swift
' Complete API Libraries and Wrappers can be found here: ' https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__dot_net' Get File Sample in VB.netPrivateSharedSubGetFileAPITest()DimapiKey AsString="replace with your api key here"DimfileID AsString="replace with the returned file ID when calling sendfile API"Dimdir AsString="C:emp" TryDimfilePath =GetFileAsync(apiKey,fileID,dir).Result Console.Write($"File{filePath} retrieved successfully.")Catchex AsException Console.Write(ex.InnerException.Message)EndTryConsole.ReadKey()EndSubPublicSharedAsync FunctionGetFileAsync(ByValapiKey AsString,ByValfileID AsString,ByValdir AsString)AsTask(OfString)IfString.IsNullOrEmpty(apiKey)ThenThrowNewException("Error: apiKey is required")IfString.IsNullOrEmpty(fileID)ThenThrowNewException("Error: fileID is required")Dimuri AsUri =NewUri($"https://bulkapi.zerobounce.net/v2/getfile?api_key={apiKey}&file_id={fileID}")Usingclient =NewHttpClient()Usingrequest =NewHttpRequestMessage(HttpMethod.Get,uri)Usingresponse =Await client.SendAsync(request,HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(False)UsingstreamToReadFrom AsStream=Await response.Content.ReadAsStreamAsync()Ifresponse.IsSuccessStatusCode =FalseThenDim[error] =$"StatusCode ={CInt(response.StatusCode)},Content ={response.Content.ReadAsStringAsync().Result}" ThrowNewException([error])EndIfDimfilePath =Path.Combine(dir,response.Content.Headers.ContentDisposition.FileName)UsingstreamToWriteTo AsStream=File.Open(filePath,FileMode.Create)Await streamToReadFrom.CopyToAsync(streamToWriteTo)EndUsingReturnfilePath EndUsingEndUsingEndUsingEndUsingEndFunction
// Complete API Libraries and Wrappers can be found here: // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__dot_net// https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__c-sharp// Get File Sample in C#privatestaticvoidGetFileAPITest(){stringapiKey ="replace with your api key here";stringfileID ="replace with the returned file ID when calling sendfile API";stringdir =@"C:emp";// specify the directory where you want to save the results filetry{varfilePath =GetFileAsync(apiKey,fileID,dir).Result;Console.Write($"File{filePath} retrieved successfully.");}catch(Exceptionex){Console.Write(ex.InnerException.Message);}Console.ReadKey();}publicstaticasyncTask<string>GetFileAsync(stringapiKey,stringfileID,stringdir){if(string.IsNullOrEmpty(apiKey))thrownewException("Error: apiKey is required");if(string.IsNullOrEmpty(fileID))thrownewException("Error: fileID is required");Uriuri =newUri($"https://bulkapi.zerobounce.net/v2/getfile?api_key={apiKey}&file_id={fileID}");using(varclient =newHttpClient())using(varrequest =newHttpRequestMessage(HttpMethod.Get,uri))using(varresponse =awaitclient.SendAsync(request,HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false))using(StreamstreamToReadFrom =awaitresponse.Content.ReadAsStreamAsync()){if(response.IsSuccessStatusCode ==false){varerror =$"StatusCode={(int)response.StatusCode}, Content={response.Content.ReadAsStringAsync().Result}";thrownewException(error);}varfilePath =Path.Combine(dir,response.Content.Headers.ContentDisposition.FileName);using(StreamstreamToWriteTo =File.Open(filePath,FileMode.Create)){awaitstreamToReadFrom.CopyToAsync(streamToWriteTo);}returnfilePath;}}
<?php// Complete API Libraries and Wrappers can be found here: // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__php$request=newHttpRequest();$request->setUrl('https://bulkapi.zerobounce.net/v2/getfile');$request->setMethod(HTTP_METH_GET);$request->setQueryData(array('api_key'=>'replacewithyours','file_id'=>'replacewithyours'));$request->setHeaders(array('Postman-Token'=>'0a6c40b8-0cd4-4dbb-a57e-422558e7ab6a','cache-control'=>'no-cache'));try{$response=$request->send();echo$response->getBody();}catch(HttpException $ex){echo$ex;}?>
//Complete API Libraries and Wrappers can be found here: //https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__javaOkHttpClientclient =newOkHttpClient();Requestrequest =newRequest.Builder().url("https://bulkapi.zerobounce.net/v2/getfile?api_key=replacewithyours&file_id=replacewithyours").get().addHeader("cache-control","no-cache").addHeader("Postman-Token","d0b7d318-f3f6-47fb-842d-5622b26592c1").build();Responseresponse =client.newCall(request).execute();
# Complete API Libraries and Wrappers can be found here: # https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__pythonimporthttp.client conn =http.client.HTTPConnection("bulkapi,zerobounce,net")payload =""headers ={'cache-control':"no-cache",'Postman-Token':"9f615d7e-60af-4746-9bcc-317b1f80a6bb"}conn.request("GET","v2,getfile",payload,headers)res =conn.getresponse()data =res.read()print(data.decode("utf-8"))
// Complete API Libraries and Wrappers can be found here: // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__IOSimportFoundationletheaders =["cache-control":"no-cache","Postman-Token":"6c8cb1cb-25ed-4e56-b4cb-65e949b8bdd1"]letrequest =NSMutableURLRequest(url:NSURL(string:"https://bulkapi.zerobounce.net/v2/getfile?api_key=replacewithyours&file_id=replacewithyours")!asURL,cachePolicy:.useProtocolCachePolicy,timeoutInterval:10.0)request.httpMethod ="GET"request.allHTTPHeaderFields =headers letsession =URLSession.shared
letdataTask =session.dataTask(with:request asURLRequest,completionHandler:{(data,response,error)->Voidinif(error !=nil){print(error)}else{lethttpResponse =response as?HTTPURLResponseprint(httpResponse)}})dataTask.resume()

Endpoint Response

Successful Response

//N/A

The getfile API returns the validation results file. The returned content type is "application/octet-stream". You can get the file name from response.Content.Headers.ContentDisposition.FileName. If you are calling the API directly from the browser, you can either save or open the results file from the browser.

Error Response

{"success":false,"message":"Error messages"}