Federal Crop Insurance Quoter

To calculate insurance premiums for Yield Protection, Revenue Protection, and Revenue Protection with Harvest Price exclusion, along with their area coverage alternatives.

POST Request Federal Crop Insurance Quoter

Please note, you need to purchase a subscription key to call the API.
Please use the trial version to try now for a limited amount of uses before purchase.



The Federal Crop Insurance Quoter API is used to calculate insurance premiums for Yield Protection, Revenue Protection, and Revenue Protection with Harvest Price exclusion, along with their area coverage alternatives.


Insurance Quoter used in Ag-Analytics FarmScope.



Click the Jupyter Notebook Static Sample to view a static rendition of this APIs Jupyter Notebook.
Click the Jupyter Notebook Github Repo to access the Jupyter Notebook .ipynb files and
instructions needed in order to run this APIs Jupyter Notebook.

Request Parameters


Name Type Description
FIPS int The FIPS code of a county (e.g. 17019).
See county FIPS codes for full listing.
CropCode int The code for a crop (e.g. corn's crop code is 41).
See Crop Codes Summary for full listing.
Type int The code for the type of a crop (e.g. corn type grain is 16).
See Crop Codes Summary for full listing.
Practice int The code for the practice type of a crop (e.g. non-irrigated is 3).
See Crop Codes Summary for full listing.
PreventedPlanning int An integer in the range [0,2]. 0 = Standard, 1 = Plus 5%, 2 = Plus 1
UseTAYield int An integer in the range [0,1]. 1 = Use Trend-Adjusted Yield, 0 = do not use
Trend-Adjusted Yield
SharePercentage double A float indicating the insured share percent, in the range [0.001, 1]
TrendAdjustedYield double A double specifying the Trend-Adjusted Yield
Acres double A double specifying the acreage.
Year int An integer specifying the year that the calculation should take place for.
APHYield double A double specifying the Actual Production History Yield
Price double A double specifying the projected crop price
Volatility double A double specifying the volatility of the crop
ReturnParameters int If value is 1, parameters for the steps of the premium calculation
are included in the response. If value is 0, parameters from the
premium calculation are not included in the response.
HighRiskCode String Subcounty high risk code that the insured field is located in, and is
relevant to the specified crop, practice, and type (e.g. 'AAA').

Response Parameters


Name Type Description
Premium double[8 , 9] The eight arrays are for coverage levels 50% - 85%, index corresponding the
ascending coverage. Within each array, index values are as shown:

double[*, 0] → RP Optional, double[*, 1] → RP Basic, double[*, 2] → RP Enterprise,
double[*, 3] → RPHPE Optional, double[*, 4] → RPHPE Basic, double[*, 5] → RPHPE Enterprise,
double[*, 6] → YP Optional, double[*, 7] → YP Basic, double[*, 8] → YP Enterprise
PremiumAllAcres double[8 , 9] The premium per acre from the ‘Premium’ value multiplied by the acreage.
Has same index structure as ‘Premium’.
Subsidy double[8 , 2] The eight arrays are for coverage levels 50% - 85%, index corresponding the ascending coverage.
Within each array, index arrays are as follows:

double[* , 0] → Subsidy rate for Basic/Optional units
double[* , 1] → Subsidy rate for Enterprise units.
Liability double[8 , 1] The eight arrays are for coverage levels 50% - 85%, index corresponding the ascending coverage.
Each value is the liability at that coverage level.
TotalPremium double[8 , 9] Same structure as ‘Premium’. Values are the premiums before the subtracting the subsidy.
TotalPremiumAllAcres double[8 , 9] The total premium per acre from ‘TotalPremium’ multiplied by the acreage amount.
Has same index structure as ‘Premium’.
SubsidyAmount double[8 , 9] Same index structure as ‘Premium’. Values are the dollar amount per acre that are
subtracted from the ‘TotalPremium’ to give you the ‘Premium’.
SubsidyAmountAllAcres double[8 , 9] The subsidy amount per acre from ‘SubsidyAmountAllAcres’ multiplied by acreage
amount. Has same index structure as ‘Premium’.
Guarantee double[8 , 3] The eight arrays are for 50-85% coverage levels with index corresponding to ascending coverage level.
The values in each array are as follows:

double[* , 0] → Minimum Revenue Guarantee
double[* , 1] → Revenue guarantee
double[* , 2] → Yield guarantee
CountyLevelPrem double[5, 9] The five arrays are for coverage levels index corresponding the ascending coverage.
The values in each list match the index structure in ‘Premium’.
CountyLevelGuarantee double[5 , 3] The five arrays are for coverage levels index corresponding the ascending coverage.
The values in each array are as follows:
double[*, 0] → Minimum Revenue Guarantee
double[*, 1] → Revenue guarantee
double[*, 2] → Yield guarantee
CountyDataAvailable bool Indicates whether county level data is available for the input given.
Plans Int[] Array of unspecified length, indicating what insurance plans are available for the inputs given.
Parameters string Array of unspecified length, indicating what insurance plans are available for the inputs given.
Coverage levels (e.g. ‘50%’)
Policy (‘rp’, ‘yp’, ‘rphpe’)
Unit (‘Basic’, ‘Optional’, ‘Enterprise’)
Parameters (Parameters of the equation)



Call API

Request

Request URL

Request headers

  • (optional)
    string
  • string

Request body

{'FIPS':17081, 'CropCode':41, 'Type':16, 'Practice':3, 'PreventedPlanting':0, 'UseTAYield':1, 'UsePerAcre':1, 'SharePercentage':1.00, 'TrendAdjustedYield':129.88, 'Acres':44.56999969, 'Year':2019, 'APHYield':129.88, 'Price':4.00, 'Volatility':0.15, 'IncludeAdminFee':0.0}

Responses

200 OK

'Premium' : double[8 , 9]
The eight arrays are for coverage levels 50% - 85%, index corresponding the ascending coverage. Within each array, index values are as shown:
double[, 0] --> RP Optional
double[
, 1] --> RP Basic
double[, 2] --> RP Enterprise
double[
, 3] --> RPHPE Optional
double[, 4] --> RPHPE Basic
double[
, 5] --> RPHPE Enterprise
double[, 6] --> YP Optional
double[
, 7] --> YP Basic
double[*, 8] --> YP Enterprise

Code samples

@ECHO OFF

curl -v -X POST "https://ag-analytics.azure-api.net/FederalCropInsuranceQuoter/post"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            var uri = "https://ag-analytics.azure-api.net/FederalCropInsuranceQuoter/post?" + queryString;

            HttpResponseMessage response;

            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");

            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }

        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://ag-analytics.azure-api.net/FederalCropInsuranceQuoter/post");


            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "application/json");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "https://ag-analytics.azure-api.net/FederalCropInsuranceQuoter/post?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://ag-analytics.azure-api.net/FederalCropInsuranceQuoter/post";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://ag-analytics.azure-api.net/FederalCropInsuranceQuoter/post');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_POST);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('ag-analytics.azure-api.net')
    conn.request("POST", "/FederalCropInsuranceQuoter/post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('ag-analytics.azure-api.net')
    conn.request("POST", "/FederalCropInsuranceQuoter/post?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://ag-analytics.azure-api.net/FederalCropInsuranceQuoter/post')


request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body