FMP API Documentation
Sample PHP connection class
rights_establish detail
expected returns
/*
//===============================><===============================
//
// FMP API
//
//===============================><===============================
*/
/*
//===============================><===============================
// auth/connecting
//===============================><===============================
*/
//_1] Use the following variables:
$BASE_URL="https://filemyprelim.com/api/";
$VERSION="v3";
$API_KEY="YourKey";
$SECRET="YourSecret";
$TIME=date('U');
$TESTMODE="off";
//_2] Calculate signature
$signature=hash_hmac("sha256",$API_KEY.$VERSION.$TIME, md5($SECRET));
//_3] Set headers
$this->url=self::FMP_API_URL.self::FMP_API_VERSION.$this->endpoint;
$this->valid_time=date('U');
$this->signature=hash_hmac("sha256",self::FMP_API_KEY.self::FMP_API_VERSION.$this->valid_time, md5(self::FMP_API_SECRET));
$this->headers=array(
'X-APIKEY: '.self::FMP_API_KEY,
'X-APIVERSION: '.self::FMP_API_VERSION,
'X-AUTHTOKEN: '.$this->signature,
'X-VALIDTIME: '.$this->valid_time,
'X-TESTMODE: '.$this->testmode
);
//_4] Use correct method relative to the "verb"
if($verb=="create"){
$method="POST";
}
elseif($verb=="update"){
$method="PUT";
}
elseif($verb=="delete"){
$method="DELETE";
}
else{
$method="GET";
}
/*
//===============================><===============================
// example for auth/connecting using class (below)
//===============================><===============================
*/
USAGE:
$data['projectTyp']="private_commercial_new";
$data['partyType']="GC";
$FMP= new FMP_API_CNX('/states/AZ/rights_establish/', 'read', 'off' $data);
$FMP->get_json($data);
RESPONSE:200
Array
(
[document_title] => Preliminary 20 Day Notice
[required_for_rights] => yes
[pursuant_code] =>
[direct_contract_exempt] => no
[direct_contract_required] => no
[custom_fabrication_exempt] => no
[rental_equip_excluded] => no
[landscaping_excluded] => yes
[licence_required] => yes
[state_auth_required] => no
[strike_date] => first_furnishing
[days_to_serve_min] => 0
[days_to_serve_max] => 20
[days_rolling_lookback] => 20
[amount_floor] => 0
[amount_required] => yes
[considered_served] => sent
[prerequisite_notices] =>
[concurrent_notices] =>
[follow_on_notices] =>
[service_required] => Array
(
[OWNER] => Array
(
[0] => usps_registered
[1] => usps_certified
[2] => usps_certificate_of_mailing
)
[GC] => Array
(
[0] => usps_registered
[1] => usps_certified
[2] => usps_certificate_of_mailing
)
)
[service_if_avail] => Array
(
[LENDER] => Array
(
[0] => usps_registered
[1] => usps_certified
[2] => usps_certificate_of_mailing
)
)
[notary_required] => no
[record_with] => NA
[base_min_service] => 2020-03-15
[pullback_min_service] => 2020-03-13
[base_last_service] => 2020-04-04
[pullback_last_service] => 2020-04-03
[base_last_cutoff] => 2020-02-24
[pullback_last_cutoff] => 2020-02-24
[base_min_cutoff] => 2020-03-15
[pullback_min_cutoff] => 2020-03-13
[private_commercial_new] => Array
(
[direct_contract_exempt] => yes
[amount_floor] => 5000
)
[role_rights_available] => yes
[prelim_pack] => Array
(
[ack_type] => acknowledgement
)
[general_notes] => Array
(
[overall_scheme] =>
[related_notices] =>
[exceptions] =>
[retainage] =>
[service] =>
[furnished_description] =>
[owner_occupied] =>
[privity] =>
[homestead] =>
[custom_fabrication] =>
[rental_equip] =>
[deadlines] =>
[record_keeping] =>
[recent_changes] =>
[potential_changes] =>
[escalations] =>
[contracts] =>
[payment_bonds] =>
[public_projects] =>
[research] =>
[internal_sop] =>
)
[project_notes] =>
)
top
class FMP_API_CNX
{
const FMP_API_URL="https://filemyprelim.com/api/";
const FMP_API_VERSION="v3";
const FMP_API_KEY="YourKey";
const FMP_API_SECRET="YourSecret";
public function __construct($endpoint, $verb, $testmode)
{
$this->api_connect($endpoint, $verb, $testmode);
}
function api_connect($endpoint, $verb, $testmode)
{
$this->endpoint= $endpoint;
$this->verb= $verb;
$this->testmode= $testmode;
$this->data= $data;
if($verb=="create"){
$method="POST";
}
elseif($verb=="update"){
$method="PUT";
}
elseif($verb=="delete"){
$method="DELETE";
}
else{
$method="GET";
}
$this->method= $method;
$this->url=self::FMP_API_URL.self::FMP_API_VERSION.$this->endpoint;
$this->valid_time=date('U');
$this->signature=hash_hmac("sha256",self::FMP_API_KEY.self::FMP_API_VERSION.$this->valid_time, md5(self::FMP_API_SECRET));
$this->headers=array(
'X-APIKEY: '.self::FMP_API_KEY,
'X-APIVERSION: '.self::FMP_API_VERSION,
'X-AUTHTOKEN: '.$this->signature,
'X-VALIDTIME: '.$this->valid_time,
'X-TESTMODE: '.$this->testmode
);
}
function get_json(array $data=NULL)
{
$page=$this->curl($this->url, $this->method, $this->headers, $data);
echo $page['body'];
}
function get_pdf(array $data)
{
$this->curl_binary($this->url, $this->headers, $data);
}
function curl($url, $method, array $headers, array $data=NULL)
{
try{
$ch = curl_init();
switch ($method){
case "POST":
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
if ($data)
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
if ($data)
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
$page['url']=$url;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTREDIR, 3);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
if (empty($response)) {
$page['error']="(".__LINE__.")Curl failed with error " . curl_error($ch). " " . curl_errno($ch). " for URL ".$url;
}
else{
$page['header']=$header;
$page['code']=$code;
$page['body']=$body;
}
curl_close($ch);
}
catch(Exception $e) {
$page['error']="(".__LINE__.")Curl failed with error " . $e->getMessage(). " for URL ".$url;
}
return $page;
}
function curl_binary($url, array $headers, array $data=NULL)
{
//*** POST method only
try{
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_HEADER, 1);
curl_setopt($resource, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($resource, CURLOPT_HTTPHEADER, $headers);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_BINARYTRANSFER, 1);
$file = curl_exec($resource);
curl_close($resource);
}
catch(Exception $e) {
$page['error']="(".__LINE__.")Curl failed with error " . $e->getMessage(). " for URL ".$url;
}
if(!empty($file)){
//*** this produces an in-line PDF to the browser
$file_array = explode("\n\r", $file, 2);
$header_array = explode("\n", $file_array[0]);
foreach($header_array as $header_value) {
$header_pieces = explode(':', $header_value);
if(count($header_pieces) == 2) {
$headers[$header_pieces[0]] = trim($header_pieces[1]);
}
}
header('Content-type: ' . $headers['Content-Type']);
header('Content-Disposition: ' . $headers['Content-Disposition']);
echo substr($file_array[1], 1);
}
}
}
top
/*
//===============================><===============================
// VERB: create
//===============================><===============================
*/
DATASET STATE [success] RETURN 201 Created
DATASET STATE [failed] RETURN 400 Bad Request
DATASET STATE [unauthorized] RETURN 401 Unauthorized
DATASET STATE [duplicate] RETURN 409 Conflict
NO VALID API CREDENTIALS RETURN 403 Forbidden
MISSING REQUIRED FILES RETURN 503 Service Unavailable
/*
//===============================><===============================
// VERB: read
//===============================><===============================
*/
DATASET STATE [success] RETURN 200 OK
DATASET STATE [unauthorized] RETURN 401 Unauthorized
DATASET STATE [failed] RETURN 404 Not Found
NO VALID API CREDENTIALS RETURN 403 Forbidden
MISSING REQUIRED FILES RETURN 503 Service Unavailable
/*
//===============================><===============================
// VERB: update
//===============================><===============================
*/
DATASET STATE [success] RETURN 202 Accepted
DATASET STATE [failed] RETURN 400 Bad Request
DATASET STATE [unauthorized] RETURN 401 Unauthorized
DATASET STATE [missing] RETURN 404 Not Found
NO VALID API CREDENTIALS RETURN 403 Forbidden
MISSING REQUIRED FILES RETURN 503 Service Unavailable
/*
//===============================><===============================
// VERB: delete
//===============================><===============================
*/
DATASET STATE [success] RETURN 200 OK
DATASET STATE [unauthorized] RETURN 401 Unauthorized
DATASET STATE [failed] RETURN 404 Not Found
NO VALID API CREDENTIALS RETURN 403 Forbidden
MISSING REQUIRED FILES RETURN 503 Service Unavailable
/*
//===============================><===============================
// VERB: list
//===============================><===============================
*/
DATASET STATE [success] RETURN 200 OK
DATASET STATE [unauthorized] RETURN 401 Unauthorized
DATASET STATE [failed] RETURN 404 Not Found
NO VALID API CREDENTIALS RETURN 403 Forbidden
MISSING REQUIRED FILES RETURN 503 Service Unavailable
/*
//===============================><===============================
// search
//===============================><===============================
*/
DATASET STATE [success] RETURN 200 OK
DATASET STATE [unauthorized] RETURN 401 Unauthorized
DATASET STATE [failed] RETURN 404 Not Found
NO VALID API CREDENTIALS RETURN 403 Forbidden
MISSING REQUIRED FILES RETURN 503 Service Unavailable
top
/*
//===============================><===============================
// rights_establish_detail
//===============================><===============================
*/
INPUTS
VARIABLE | SAMPLE VALUE | DESCRIPTION |
partyType | SUB | ... |
projectType | private_commercial_new | ... |
| |
USAGE:
$data['projectTyp']="private_commercial_new";
$data['partyType']="SUB";
$FMP= new FMP_API_CNX('/states/AZ/rights_establish/', 'read', 'off' $data);
$FMP->get_json($data);
|
OUTPUT JSON
VARIABLE | SAMPLE VALUE | DESCRIPTION |
document_title | Preliminary 20 Day Notice | ... |
required_for_rights | yes | ... |
pursuant_code | | ... |
direct_contract_exempt | no | ... |
direct_contract_required | no | ... |
custom_fabrication_exempt | no | ... |
rental_equip_excluded | no | ... |
landscaping_excluded | yes | ... |
licence_required | yes | ... |
state_auth_required | no | ... |
strike_date | first_furnishing | ... |
days_to_serve_min | 0 | ... |
days_to_serve_max | 20 | ... |
days_rolling_lookback | 20 | ... |
amount_floor | 0 | ... |
amount_required | yes | ... |
considered_served | sent | ... |
prerequisite_notices | | ... |
concurrent_notices | | ... |
follow_on_notices | | ... |
service_required |
(
[OWNER] => Array
(
[0] => usps_registered
[1] => usps_certified
[2] => usps_certificate_of_mailing
)
)
| ... |
service_if_avail |
(
[LENDER] => Array
(
[0] => usps_registered
[1] => usps_certified
[2] => usps_certificate_of_mailing
)
)
| ... |
notary_required | no | ... |
record_with | NA | ... |
base_min_service | 2020-03-15 | ... |
pullback_min_service | 2020-03-13 | ... |
base_last_service | 2020-04-04 | ... |
pullback_last_service | 2020-04-03 | ... |
base_last_cutoff | 2020-02-24 | ... |
pullback_last_cutoff | 2020-02-24 | ... |
base_min_cutoff | 2020-03-15 | ... |
pullback_min_cutoff | 2020-03-13 | ... |
role_rights_available | yes | ... |
prelim_pack |
(
[ack_type] => acknowledgement
)
| ... |
general_notes | | ... |
project_notes | this has info | ... |